Skip to content

Exposed StateSet metrics "state" label do not follow OpenMetrics protocol  #2879

@bwplotka

Description

@bwplotka

Context

In Prometheus, we are working on OpenMetrics 2.0.

We are investigating what to do with "StateSet" metric -- notably if there's anything to improve in this iteration or even -- if we should remove this type for now (unlikely), given there's still pending consensus on what use case this metric type should aim for and how it should be implemented/consumed. Currently all known implementations treat stateset metrics as gauges.

During research I noticed that KSM allows emitting statesets, but they are almost following the spec, notably the state label:

StateSets MUST have one sample per State in the MetricPoint. Each State's sample MUST have a label with the MetricFamily name as the label name and the State name as the label value. The State sample's value MUST be 1 if the State is true and MUST be 0 if the State is false.

From what I see any stateset custom resource state metric will produce stateset like

kube_customresource_status_phase{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1", phase="Pending"} 1
kube_customresource_status_phase{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1", phase="Bar"} 0
kube_customresource_status_phase{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1", phase="Baz"} 0

But this violates the spec, because the phase label must be exactly the metric name, so kube_customresource_status_phase.

Just to be clear, I am not arguing longer label is more useful or not, the problem is that if systems ever implement "native" implementation, KSM metrics won't work. For now it probably doesn't matter.

Questions

Given the above I'd like to use this occasion to ask:

  1. Do you have any feedback/needs from StateSet future use cases in the discussions I provided (notably next version of OpenMetrics: OM 2.0: Should stateset be represented in a Complex/Composite format? prometheus/OpenMetrics#310)?
  2. What would be your plan for this issue? (it's ok to say we are not going to fix it!) - I don't think anyone is blocked right now.

FYI: KSM seems to be the first popular production component that uses StateSet, to my understanding.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    Status

    Needs Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions