I have installed the Prometheus plugin on my test system and it returns 2 Content-Type headers, which is confusing my Prometheus scraper.
You can see it for yourself as I have not protected the /metrics route yet: https://conferences-test.ctbto.org/metrics
The first Content-Type header is text/html. The second Content-Type header is the correct application/openmetrics-text; version=0.0.1
Here is what I see in my browser (Firefox):
Content-Encoding
gzip
Content-Length
1151
Content-Type
text/html; charset=utf-8
Content-Type
application/openmetrics-text; version=0.0.1; charset=utf-8
Set-Cookie
ctbtolb=!UG7IEzYLt2qCLg2kJz4Uo/tXEybWOdsISKTQJJ26UlTPNlEhWzAxp3DOLJt/d+RljSZX+1oRO+xBeNY=; path=/; Httponly; Secure
Strict-Transport-Security
max-age=31536000
X-Cached
yes
X-Indico-URL
/metrics
Is this a bug? Can the first Content-Type header be removed?
This has been fixed in v3.3.1 of the plugin
I use the version 3.3.3 of the plugin:
RUN /bin/bash && . /opt/indico/.venv/bin/activate && git clone https://github.com/indico/indico-plugins.git && \
cd indico-plugins && git checkout v3.3.3 && cd prometheus && ${pip} install .
Hmmm interesting:
((.venv) ) indico@9cc40e78074d:/opt/indico/.venv/bin$ pip list | grep prom
indico-plugin-prometheus 3.3
So there is a tag 3.3.3 on the indico plugins repository, but each plugin has its own version?
Yes, indico-plugins
is just the meta package that bundles all plugins as dependencies. Updating it to 3.3.4 will also give you the latest Prometheus plugin though.
Thanks @ThiefMaster it works fine with v3.3.4.
Just out of curiosity: why did you choose to return text/plain as the Content-Type header, instead of
application/openmetrics-text; version=0.0.1
?
I’m using whatever the prometheus_client
library returns - my fix simply ensures that headers previously set by Flask are overwritten instead of extended.