I have a Quarkus project (v3.8.1), with the extensions quarkus-micrometer
and quarkus-micrometer-registry-prometheus
. My problem is that when calling the metrics endpoint from Postman, I get a 200 OK, but when the endpoint is scraped from the Prometheus server, I get a 406 Not Acceptable response.
This is my config in the application.yml
:
quarkus:
micrometer:
enabled: true
export:
prometheus:
enabled: true
path: metrics/prometheus
My prometheus.yml
config :
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'quarkus-micrometer'
metrics_path: '/q/metrics/prometheus'
scrape_interval: 3s
static_configs:
- targets: ['MY_IP:8080']
I tried comparing the two requests, and I found that the request coming from the Prometheus server scraping contains Accept headers, and this is the headers with “application/openmetrics-text;…” that are responsible from the 406.
Example request from Prometheus server scraping :
date INFO [io.qua.htt.access-log] (vert.x-eventloop-thread-2)
GET /q/metrics/prometheus HTTP/1.1
Accept: application/openmetrics-text;version=1.0.0;q=0.5
Accept: application/openmetrics-text;version=0.0.1;q=0.4
Accept: text/plain;version=0.0.4;q=0.3
Accept: */*;q=0.2
User-Agent: Prometheus/2.52.0
Host: MY_IP:8080
Accept-Encoding: gzip
X-Prometheus-Scrape-Timeout-Seconds: 3
Example request from Postman :
date INFO [io.qua.htt.access-log] (vert.x-worker-thread-1)
GET /q/metrics/prometheus HTTP/1.1
User-Agent: PostmanRuntime/7.37.3
Host: MY_IP:8080
Postman-Token: 1509bc27-58ed-498f-9d74-73ee5348eb97
Accept-Encoding: gzip
Accept-Encoding: deflate
Accept-Encoding: br
I expect finding a solution for having 200 OK response on the endpoint /q/metrics/prometheus
, even with the Accept header application/openmetrics-text
, or find a way to not send that header from the Prometheus server.