Skip to content

Metrics handler not falling back to gauge on text/plain negotiations #2587

@zellaa

Description

@zellaa

What happened:

When a prometheus request is sent with the protobuf format, the KSM metrics handler should negotiate the content type to be text as protobuf is not supported. However, the metrics handler also responds with type info which is not accepted by prometheus for this content type: invalid metric type "info".

What you expected to happen: Similar to issue #2270, one solution is to fallback to gauge type when negotiating text/plain as well as protobuf.

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

Running prometheus with --enable-feature=native-histograms with a scrape job that defines a fallback PrometheusText0,0,4 formatm and run KSM with any info metrics.

Anything else we need to know?:
this issue seems to have been referenced here and here.

Manually tested if the invalid metric type: info error popped up for various prometheus request + fallback formats:

Prometheus requested format(s) Fallback format Result
OpenMetrics0.0.1, OpenMetrics1.0.0 PrometheusText0.0.4 OK
OpenMetrics0.0.1, OpenMetrics1.0.0 N/A OK
PrometheusProto PrometheusText0.0.4 Fail
PrometheusProto OpenMetrics1.0.0 Fail
PrometheusProto OpenMetrics0.0.1 Fail
PrometheusText1.0.0 PrometheusText0.0.4 Fail

There is another issue here (#2248) where v2.12 was supposed to have the fix for the issue I am seeing, but the invalid type error persists.

Environment:

  • kube-state-metrics version: 2.14
  • Kubernetes version (use kubectl version):client v1.28.0 + server v1.31.1-gke.2105000
  • Cloud provider or hardware configuration:
  • Other info: Prometheus version 3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions