vmware-archive / eventrouter

A simple introspective kubernetes service that forwards events to a specified sink.
Apache License 2.0
886 stars 252 forks source link

Prometheus metrics doesn't report events even when 'enable-prometheus' is true #89

Closed yejingchen closed 4 years ago

yejingchen commented 5 years ago

After commit 6a815be, the http /metrics interface gives no kubernetes events either with enable-prometheus set to true or not specified at all. Events are indeed recorded because it is logged in glog.

After fast skimming I think the viper imported in eventrouter.go is not the same instance in main.go so the config doesn't apply. But since I don't know about go I maybe wrong. https://github.com/heptiolabs/eventrouter/blob/6a815beeeab89b29e5c283f7c793964b0b67e05a/eventrouter.go#L25

cyrus-mc commented 5 years ago

@yejingchen I pushed a quick fix for this.

The issue is that the init function is called before loadConfig (which sets enable-prometheus). Therefore the config value is not found and the if statement evaluated false. I moved what was in the init function to the NewEventRouter function.