Kube-state-metrics: Label not following Prometheus best practices in labels metrics

Created on 2 Jul 2020  路  2Comments  路  Source: kubernetes/kube-state-metrics

Is this a BUG REPORT or FEATURE REQUEST?:

/kind bug

What happened:

I created a pod with label in camelCase, marketplace.operatorSource which was then translated by kube-state-metrics into a Prometheus label part of the kube_pod_labels metrics.
To my surprise, promlint then flagged the kube_pod_labels metric as a metric not following the best practices with an error saying that label names should be written in snake_case and not camelCase. After looking into it, I found the following metrics exposed by ksm:

kube_pod_labels{label_marketplace_operatorSource=""}

What you expected to happen:

I expected kube_state_metrics to transform the Kubernetes label into the following valid Prometheus label:

kube_pod_labels{label_marketplace_operator_source=""}

How to reproduce it (as minimally and precisely as possible):

Create a pod with a label in camelCase.

Anything else we need to know?:

AFAIK, there is nothing in the Kubernetes label syntax that is preventing to have a label in camelCase so I would expect kube-state-metrics to transform it in snake_case.

Environment:
kube-state-metrics: v1.9.7

kinbug

Most helpful comment

In this case, I think we can make use of the "_confictN" renaming mechanism that was recently introduced in #1156.

All 2 comments

Changing label name from user-provided value to something else can cause potential conflicts. What if one pod had marketplace.operatorSource and the second one marketplace.operator_source?

In this case, I think we can make use of the "_confictN" renaming mechanism that was recently introduced in #1156.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dghubble picture dghubble  路  3Comments

chasemaier picture chasemaier  路  5Comments

jackzampolin picture jackzampolin  路  8Comments

roobre picture roobre  路  7Comments

terinjokes picture terinjokes  路  4Comments