kube-state-metrics icon indicating copy to clipboard operation
kube-state-metrics copied to clipboard

Validate metrics

Open rexagod opened this issue 3 years ago • 5 comments

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

rexagod avatar Sep 02 '22 18:09 rexagod

cc @dgrisonnet @mrueg

rexagod avatar Sep 09 '22 10:09 rexagod

/lgtm /hold

fpetkovski avatar Sep 09 '22 13:09 fpetkovski

[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

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

k8s-ci-robot avatar Sep 09 '22 13:09 k8s-ci-robot

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

dgrisonnet avatar Sep 09 '22 15:09 dgrisonnet

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)?

rexagod avatar Sep 13 '22 05:09 rexagod

Then I guess it was already done and we somehow forgot :sweat_smile:, sorry about that @rexagod.

dgrisonnet avatar Sep 23 '22 17:09 dgrisonnet