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

Add Collector version to Prometheus Remote Write Exporter user-agent header #3094

Merged

Conversation

dhruv-vora
Copy link
Contributor

@dhruv-vora dhruv-vora commented May 4, 2021

Description:
In order to better understand usage patterns for the Prometheus Remote Write exporter in the Collector, we’re adding the Collector name and version info to the user-agent request header in the Prometheus Remote Write exporter.

@dhruv-vora dhruv-vora requested a review from a team May 4, 2021 18:31
Copy link
Member

@alolita alolita left a comment

Choose a reason for hiding this comment

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

lgtm.

@alolita
Copy link
Member

alolita commented May 4, 2021

Requesting reviews from @Aneurysm9 @anuraaga

@dhruv-vora dhruv-vora changed the title Add collector version to prometheus remote write exporter user-agent header Add Collector version to Prometheus Remote Write Exporter user-agent header May 4, 2021
)

const (
maxConcurrentRequests = 5
maxBatchByteSize = 3000000
prwVersion = "0.1.0"
Copy link
Member

Choose a reason for hiding this comment

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

Why defining this version? Why not using the version from the BuildInfo?

Copy link
Member

Choose a reason for hiding this comment

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

Or from internal/version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The version from the BuildInfo would be the version of the Collector. The prwVersion is for the X-Prometheus-Remote-Write-Version. Hence, I have defined this version separately.

Copy link
Contributor

Choose a reason for hiding this comment

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

It appears to be the format of the data, something like a content encoding.

But do you need it in the user agent? It's already sent as a header.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need this information as we are using only the User-Agent header information in the back-end AMP service

@@ -321,8 +327,8 @@ func (prwe *PrwExporter) execute(ctx context.Context, writeReq *prompb.WriteRequ
// https://cortexmetrics.io/docs/apis/#remote-api
req.Header.Add("Content-Encoding", "snappy")
req.Header.Set("Content-Type", "application/x-protobuf")
req.Header.Set("X-Prometheus-Remote-Write-Version", "0.1.0")
req.Header.Set("User-Agent", "OpenTelemetry-Collector/"+version.Version)
req.Header.Set("X-Prometheus-Remote-Write-Version", prwVersion)
Copy link
Contributor

Choose a reason for hiding this comment

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

We need this information as we are using only the User-Agent header information in the back-end AMP service

If this is true, can we remove this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not think that we can remove that line as per the requirement in https://cortexmetrics.io/docs/api/#remote-write.

Copy link
Contributor

Choose a reason for hiding this comment

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

So if it's sent to the backend here we don't need it in the user agent right? It's a bit weird to have the same information in two headers, it's better if the backend can do what it needs based on all the headers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I understand that. Actually the AMP backend sends the logs to CloudWatch logs and in these logs, only the user-agent field is present. That was the reason I added the X-Prometheus-Remote-Write-Version information in the user-agent header. @alolita and @Aneurysm9, could you take a look at this to determine if X-Prometheus-Remote-Write-Version information is required in the user-agent header. If not, I can remove it

Copy link
Member

Choose a reason for hiding this comment

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

X-Prometheus-Remote-Write-Version needs to be a distinct header per the PRW spec. I'm not sure it needs to be in the user agent header, though. Particularly if prwVersion is a constant, as it is here, we can derive the PRW version from the collector version. If that ever changes we can re-evaluate in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want it in the user agent header as the other distinct header is not present in the CW Logs from AMP, hence adding it in the user agent header would be way to get this information. Also about deriving the prwVersion from the collector version, I do not think they are related and so I don't think it can be derived

Copy link
Member

Choose a reason for hiding this comment

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

  1. the AMP log processing pipeline is an AWS internal detail that we can change independent of this exporter, the relevant information is in the HTTP request.
  2. the collector implements a single version of the PRW protocol and there is no indication that that will change, even if the PRW protocol version changes. There will be a 1:1 correspondence between collector version and supported PRW protocol version. Therefore, the information that would be conveyed by having the PRW version data in the user agent header is already present in the collector version data.

Copy link
Member

Choose a reason for hiding this comment

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

I agree there will be a 1:1 correspondence between the Collector version and supported PRW protocol version information.

@bogdandrutu bogdandrutu merged commit 10bbaf8 into open-telemetry:main May 14, 2021
Frefreak pushed a commit to Frefreak/opentelemetry-collector that referenced this pull request May 15, 2021
…header (open-telemetry#3094)

* Add collector version to prometheus remote write exporter user agent

* Add collector version to prometheus remote write exporter user agent

* refined user-agent header and tests

* pre-computed user-agent and updated functions

* removed startInfo from PrwExporter struct

* removed usage of GitHash

* Add collector version to prometheus remote write exporter user agent

* Add collector version to prometheus remote write exporter user agent

* refined user-agent header and tests

* pre-computed user-agent and updated functions

* removed startInfo from PrwExporter struct

* removed usage of GitHash

* updated to use BuildInfo and LongName

* renamed variables to use new convention

* removed X-Prometheus-Remote-Write-Version/0.1.0 from User-Agent header

Co-authored-by: Anthony J Mirabella <a9@aneurysm9.com>
dashpole pushed a commit to dashpole/opentelemetry-collector that referenced this pull request Jun 14, 2021
…header (open-telemetry#3094)

* Add collector version to prometheus remote write exporter user agent

* Add collector version to prometheus remote write exporter user agent

* refined user-agent header and tests

* pre-computed user-agent and updated functions

* removed startInfo from PrwExporter struct

* removed usage of GitHash

* Add collector version to prometheus remote write exporter user agent

* Add collector version to prometheus remote write exporter user agent

* refined user-agent header and tests

* pre-computed user-agent and updated functions

* removed startInfo from PrwExporter struct

* removed usage of GitHash

* updated to use BuildInfo and LongName

* renamed variables to use new convention

* removed X-Prometheus-Remote-Write-Version/0.1.0 from User-Agent header

Co-authored-by: Anthony J Mirabella <a9@aneurysm9.com>
ankitnayan pushed a commit to SigNoz/opentelemetry-collector that referenced this pull request Jul 27, 2021
…header (open-telemetry#3094)

* Add collector version to prometheus remote write exporter user agent

* Add collector version to prometheus remote write exporter user agent

* refined user-agent header and tests

* pre-computed user-agent and updated functions

* removed startInfo from PrwExporter struct

* removed usage of GitHash

* Add collector version to prometheus remote write exporter user agent

* Add collector version to prometheus remote write exporter user agent

* refined user-agent header and tests

* pre-computed user-agent and updated functions

* removed startInfo from PrwExporter struct

* removed usage of GitHash

* updated to use BuildInfo and LongName

* renamed variables to use new convention

* removed X-Prometheus-Remote-Write-Version/0.1.0 from User-Agent header

Co-authored-by: Anthony J Mirabella <a9@aneurysm9.com>
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.

6 participants