Skip to content

Accept header mismatch for OpenMetrics #702

@jonatan-ivanov

Description

@jonatan-ivanov

The latest(2.30.0) version of Prometheus sends out the following request when scraping:

GET /actuator/prometheus HTTP/1.1
Host: host.docker.internal:8080
User-Agent: Prometheus/2.30.0
Accept: application/openmetrics-text; version=0.0.1,text/plain;version=0.0.4;q=0.5,*/*;q=0.1
Accept-Encoding: gzip
X-Prometheus-Scrape-Timeout-Seconds: 10

In the Accept header, the version of openmetrics-text is 0.0.1 (see scrape.go).
In the Java client, the Content-Type constant does not match to this, its version is 1.0.0 (see TextFormat):

CONTENT_TYPE_OPENMETRICS_100 = "application/openmetrics-text; version=1.0.0; charset=utf-8";

The python client uses 0.0.1 too. Shouldn't all use the same version (1.0.0) or should the Java client use (0.0.1)?

It also seems that TextFormat::chooseContentType takes this into account:

for (String accepts : acceptHeader.split(",")) {
if ("application/openmetrics-text".equals(accepts.split(";")[0].trim())) {
return CONTENT_TYPE_OPENMETRICS_100;
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions