Skip to content

/metrics endpoint bad content-type #3689

@FreezerJohn

Description

@FreezerJohn

Describe the bug
The /metrics endpoints uses content-type: application/json, while Prometheus v3 expects e.g. plain/text

$ curl --head http://10.42.0.72:8000/metrics
HTTP/1.1 200 OK
content-length: 14299
content-type: application/json; charset=utf-8
access-control-allow-headers: *
access-control-allow-methods: *
access-control-allow-origin: *

Prometheus throws:
Error scraping target: received unsupported Content-Type "application/json; charset=utf-8" and no fallback_scrape_protocol specified for target

Image

Seems like Prometheus v2 quietly tolerated this, and v3 is more strict. See https://prometheus.io/docs/prometheus/latest/migration/#scrape-protocols

Workaround
Explicitly set fallbackScrapeProtocol in a ScrapeConfig for OVMS.

To Reproduce
Steps to reproduce the behavior:

  1. Run OVMS with --metrics_enable and --rest_port=8000
  2. Setup Prometheus v3 to scrape the /metrics endpoint

Expected behavior
/metrics endpoint uses correct content-type in header

Configuration

  1. OVMS version: 4.0.0
  2. Prometheus v3

My setup was k3s with prometheus-community/kube-prometheus-stack and OVMS installed via Helm
https://github.com/openvinotoolkit/operator/tree/main/helm-charts/ovms

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions