Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

added support for optional clusterName via config file #173

Closed
wants to merge 1 commit into from
Closed

added support for optional clusterName via config file #173

wants to merge 1 commit into from

Conversation

xmcqueen
Copy link
Contributor

When there are multiple clusters in an area its essential to have the event's clustername associated with each event. The event object exposed by Kubernetes provides a clustername, but it does not set it. This PR sets the clustername.

#167

… events need a clustername when multiple clusters are in service
@xmcqueen
Copy link
Contributor Author

xmcqueen commented Dec 13, 2021

The build is failing because it needs a mod tidy or something. The changes do not introduce any new dependencies. However, if I do that the PR becomes very noisy with unrelated vendor changes. Should I do a mod tidy and update the PR?

Maybe a 1 PR with nothing but mod tidy, and then a second one for this changeset would be easy to manage. A mod tidy is probably needed somewhere at this point.

@anannaya
Copy link

anannaya commented Mar 29, 2022

@xmcqueen Is it working for you. I built image from this PR , still i see empty string clustername.
below is my configuration

  config.yaml: |
    logLevel: debug
    logFormat: json
    throttlePeriod: 10
    ClusterName: staging-eks
    kubeQPS: 60
    kubeBurst: 60
    route:
      routes:
      - match:
        - receiver: "elasticsearch-dump"
    receivers:
    - name: "elasticsearch-dump"
      elasticsearch:
        hosts:
        - http://aws-es-log.staging.xxxxxx.com:80
        index: logstash-kube-events
        indexFormat: "logstash-kube-events-{2006-01-02}"
        deDot: true
        useEventID: true
        layout:
          component: '{{ .Source.Component }}'
          count: '{{ .Count }}'
          '@timestamp': '{{ .GetTimestampISO8601 }}'
          host: '{{ .Source.Host }}'
          clustername: '{{ .ClusterName }}'
          kind: '{{ .InvolvedObject.Kind }}'
          labels: '{{ toJson .InvolvedObject.Labels}}'
          message: '{{ .Message }}'
          name: '{{ .InvolvedObject.Name }}'
          namespace: '{{ .Namespace }}'
          reason: '{{ .Reason }}'
          type: '{{ .Type }}'

@xmcqueen
Copy link
Contributor Author

Yes its in very heavy usage over here. It works great. I wonder if the problem is your use of ClusterName in the yaml instead of clusterName.

Here's the annotation for the struct where the yaml is decoded: pkg/exporter/config.go +16


	// TODO: I am not sure what to do here.
	LogLevel       string                    `yaml:"logLevel"`
	LogFormat      string                    `yaml:"logFormat"`
	ThrottlePeriod int64					 `yaml:"throttlePeriod"`
	ThrottlePeriod int64                     `yaml:"throttlePeriod"`
	ClusterName    string                    `yaml:"clusterName,omitempty"`
	Namespace      string                    `yaml:"namespace"`
	LeaderElection kube.LeaderElectionConfig `yaml:"leaderElection"`
	Route          Route    

@anannaya
Copy link

Yes its in very heavy usage over here. It works great. I wonder if the problem is your use of ClusterName in the yaml instead of clusterName.

Here's the annotation for the struct where the yaml is decoded: pkg/exporter/config.go +16


	// TODO: I am not sure what to do here.
	LogLevel       string                    `yaml:"logLevel"`
	LogFormat      string                    `yaml:"logFormat"`
	ThrottlePeriod int64					 `yaml:"throttlePeriod"`
	ThrottlePeriod int64                     `yaml:"throttlePeriod"`
	ClusterName    string                    `yaml:"clusterName,omitempty"`
	Namespace      string                    `yaml:"namespace"`
	LeaderElection kube.LeaderElectionConfig `yaml:"leaderElection"`
	Route          Route    

Thanks it works, Very sharp Eye.

@fpants
Copy link

fpants commented Jul 14, 2022

@xmcqueen can I open a PR with this code for the maintained fork here? https://github.com/resmoio/kubernetes-event-exporter

@xmcqueen
Copy link
Contributor Author

xmcqueen commented Jul 14, 2022

wow I had no idea. Yes and maybe I'll jump over there too. I've got 2 PRs queued up here now. Thanks

I need metrics in there. I've got a PR in here that adds prometheus metrics.

Wow and the vendor directory is gone too! I was going to open a ticket about that!

Yes, I'm jumping over to this new repo. You go ahead with the clusterName PR.

I'll get the prometheus metrics PR going.

@xmcqueen xmcqueen closed this by deleting the head repository Aug 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants