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

accept text/plain type by default for prometheus client scraping #24622

Merged
merged 3 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix GCP not able to request Cloudfunctions metrics if a region filter was set {pull}24218[24218]
- Fix type of `uwsgi.status.worker.rss` type. {pull}24468[24468]
- Ignore unsupported derive types for filesystem metricset. {issue}22501[22501] {pull}24502[24502]
- Accept text/plain type by default for prometheus client scraping. {pull}24622[24622]

*Packetbeat*

Expand Down
6 changes: 5 additions & 1 deletion metricbeat/helper/prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ import (
"github.com/elastic/beats/v7/metricbeat/mb"
)

const acceptHeader = `application/openmetrics-text; version=0.0.1,text/plain;version=0.0.4;q=0.5,*/*;q=0.1`
const (
promTextHeader = `text/plain;version=0.0.4;q=0.5,*/*;q=0.1`
openmetricsHeader = `application/openmetrics-text; version=0.0.1,text/plain;version=0.0.4;q=0.5,*/*;q=0.1`
newly12 marked this conversation as resolved.
Show resolved Hide resolved
acceptHeader = promTextHeader
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metricbeat has two collectors, one for prometheus, and another one for openmetrics, they are mostly the same so far, but I think it would make sense if each collector configured the default headers of their choice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comments. yeah but I think for application/openmetrics-text the parser would only work for 'previous' openmetrics format, not the new one, so sending Accept: application/openmetrics-text could give target endpoints the chance to respond with new format, while at this moment, text/plain prometheus format should still be compatible from their perspective.

This PR is more like a workaround as being mentioned in the issue, the solution would still be updating the parser as suggested by @exekias .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why application/openmetrics-text; version=0.0.1 includes the new openmetrics types 🤔 . Shouldn't that change be applied with a new version so as to be backwards compatible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. I think somehow that is not happening and hence breaking things.

)

// Prometheus helper retrieves prometheus formatted metrics
type Prometheus interface {
Expand Down