kube-state-metrics
kube-state-metrics copied to clipboard
Validate metrics
What this PR does / why we need it: Validate metrics that are served over the metrics endpoint using promtool in the e2e test flow.
How does this change affect the cardinality of KSM: No change.
Which issue(s) this PR fixes: Fixes #1793
cc @dgrisonnet @mrueg
/lgtm /hold
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: fpetkovski, rexagod
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~OWNERS~~ [fpetkovski]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
Since this is a step of e2e testing and we want to get rid of shell scripts as much as possible in kube-state-metrics, I would be in favor of doing the check in a Golang test with the promlint library rather than using the tool directly: https://godocs.io/github.com/prometheus/client_golang/prometheus/testutil/promlint.
This is essentially what promlint check metrics is doing internally: https://github.com/prometheus/prometheus/blob/4927e1353786c89e847e39c41a05a6f8ee464465/cmd/promtool/main.go#L713-L748
I just looked at the e2e suite, and it seems we are already doing this: https://github.com/kubernetes/kube-state-metrics/blob/master/tests/e2e/main_test.go#L78-L95 (CheckMetrics)?
Then I guess it was already done and we somehow forgot :sweat_smile:, sorry about that @rexagod.