Skip to content

Fix Content-Type header for Prometheus compliance#104

Open
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-101
Open

Fix Content-Type header for Prometheus compliance#104
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-101

Conversation

Copy link

Copilot AI commented Aug 3, 2025

The PM2 Prometheus exporter was sending an incomplete Content-Type header that caused Prometheus to report scraping errors:

Error scraping target: non-compliant scrape target sending blank Content-Type and no fallback_scrape_protocol specified for target

While a Content-Type header was being set, it was missing the required charset=utf-8 parameter that Prometheus expects according to the exposition format specification.

Before:

Content-Type: text/plain; version=0.0.4

After:

Content-Type: text/plain; version=0.0.4; charset=utf-8

This change ensures full compliance with the Prometheus exposition format and eliminates the need for users to configure workarounds like fallback_scrape_protocol: "PrometheusText0.0.4" in their Prometheus scrape configs.

The fix is minimal and surgical - only adding the missing charset parameter to the existing Content-Type header without affecting any other functionality.

Fixes #101.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits August 3, 2025 19:47
Co-authored-by: saikatharryc <15653282+saikatharryc@users.noreply.github.com>
Co-authored-by: saikatharryc <15653282+saikatharryc@users.noreply.github.com>
Copilot AI changed the title [WIP] No ContentType Header cause Prometheus Error Fix Content-Type header for Prometheus compliance Aug 3, 2025
Copilot AI requested a review from saikatharryc August 3, 2025 19:55
@ths83
Copy link

ths83 commented Sep 5, 2025

@saikatharryc Is it possible to merge this MR soon ?

@saikatharryc saikatharryc marked this pull request as ready for review September 5, 2025 14:30
@ths83
Copy link

ths83 commented Sep 5, 2025

@saikatharryc Thanks for opening the MR! Should you also merge it manually?

@saikatharryc
Copy link
Owner

@ths83 - i realized that i did not maintain it for a while and even if i merge this it wont release automatically to the npm.

@aroy314
Copy link

aroy314 commented Dec 29, 2025

can we merge and release please ?
in the meantime if you need your prometheus to work without it, add fallback_scrape_protocol in your config :

prometheus['scrape_configs'] = [
	{
	 'job_name': 'node',
	 'fallback_scrape_protocol' => 'PrometheusText0.0.4', # for pm2 content-type header
	 'static_configs' => [
	   'targets' => ['domain.com:9209'],
	 ],
	}
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No ContentType Header cause Prometheus Error

4 participants