weaveworks / launcher

Weave Cloud Launcher
Apache License 2.0
10 stars 13 forks source link

Expose prom metrics for k8s events #196

Closed dlespiau closed 6 years ago

dlespiau commented 6 years ago

I'd like to gather prometheus metrics on how many k8s events are fired in dev so we can decide how we'd store k8s events if we were to send them to weave cloud.

This PR does just that, with a bit of cleanup fixes here and there. Installing WC looks like:

launcher_events_total{involved_object="DaemonSet",reason="SuccessfulCreate",type="Normal"} 2
launcher_events_total{involved_object="Deployment",reason="ScalingReplicaSet",type="Normal"} 5
launcher_events_total{involved_object="Node",reason="FailedToStartNodeHealthcheck",type="Warning"} 1
launcher_events_total{involved_object="Pod",reason="Created",type="Normal"} 9
launcher_events_total{involved_object="Pod",reason="Pulled",type="Normal"} 9
launcher_events_total{involved_object="Pod",reason="SandboxChanged",type="Normal"} 1
launcher_events_total{involved_object="Pod",reason="Scheduled",type="Normal"} 6
launcher_events_total{involved_object="Pod",reason="Started",type="Normal"} 9
launcher_events_total{involved_object="Pod",reason="SuccessfulMountVolume",type="Normal"} 15
launcher_events_total{involved_object="ReplicaSet",reason="SuccessfulCreate",type="Normal"} 5

Also, we can now test the agent outside of the cluster, for instance, for this PR:

./build/agent -wc.token=foo -feature.install-agents=false -feature.kubernetes-events=true -log.level=debug
dlespiau commented 6 years ago

Thanks for the review! Added a last commit to expose the port that has the prom metrics so prometheus can scrape the metrics.