Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set plain/text Content-Type for prometheus exporter #496

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

snaggen
Copy link
Contributor

@snaggen snaggen commented Jun 27, 2024

Playing around with different tools to view metrics, I found that some tool complained about not having Content-Type text/plain. So this PR fixes that.

@sgrebnov
Copy link

sgrebnov commented Jul 8, 2024

Encountered with the same issue when using this crate and Datadog

@sgrebnov
Copy link

sgrebnov commented Jul 8, 2024

I've manually applied this fix and confirmed that the Prometheus exporter is now compliant with the DataDog Prometheus scraper.

Prometheus Exposition Format and Content-Type header:
https://prometheus.io/docs/instrumenting/exposition_formats/#text-based-format

@tobz
Copy link
Member

tobz commented Jul 10, 2024

Seems reasonable to me! 👍🏻

@tobz tobz added C-exporter Component: exporters such as Prometheus, TCP, etc. E-simple Effort: simple. T-bug Type: bug. S-awaiting-release Status: awaiting a release to be considered fixed/implemented. labels Jul 10, 2024
@tobz tobz merged commit 6b603f9 into metrics-rs:main Jul 10, 2024
12 checks passed
@tobz tobz removed the S-awaiting-release Status: awaiting a release to be considered fixed/implemented. label Jul 13, 2024
@tobz
Copy link
Member

tobz commented Jul 13, 2024

Released as [email protected].

Thanks again for your contribution!

Raphexion added a commit to eigerco/snarkOS that referenced this pull request Dec 3, 2024
When prometheus updates to v3, it is becoming stricter with the
Content-Type of the response.

https://prometheus.io/docs/prometheus/3.0/migration/#scrape-protocols

```
Prometheus v3 is more strict concerning the Content-Type header received when scraping.
Prometheus v2 would default to the standard Prometheus text protocol if the target being
scraped did not specify a Content-Type header or if the header was unparsable or unrecognised.
This could lead to incorrect data being parsed in the scrape. Prometheus v3 will now fail the scrape in such cases.
```

The Content-Type is updated in dependency. So all we have to do is
update the version.

From the metrics/metrics-exporter-prometheus CHANGELOG.md:

```

- Update the `Content-Type` response header to `text/plain`, matching the Exposition format
  specification. ([AleoNet#496](metrics-rs/metrics#496))
```
Raphexion added a commit to eigerco/snarkOS that referenced this pull request Dec 18, 2024
When prometheus updates to v3, it is becoming stricter with the
Content-Type of the response.

https://prometheus.io/docs/prometheus/3.0/migration/#scrape-protocols

```
Prometheus v3 is more strict concerning the Content-Type header received when scraping.
Prometheus v2 would default to the standard Prometheus text protocol if the target being
scraped did not specify a Content-Type header or if the header was unparsable or unrecognised.
This could lead to incorrect data being parsed in the scrape. Prometheus v3 will now fail the scrape in such cases.
```

The Content-Type is updated in dependency. So all we have to do is
update the version.

From the metrics/metrics-exporter-prometheus CHANGELOG.md:

```

- Update the `Content-Type` response header to `text/plain`, matching the Exposition format
  specification. ([AleoNet#496](metrics-rs/metrics#496))
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-exporter Component: exporters such as Prometheus, TCP, etc. E-simple Effort: simple. T-bug Type: bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants