fix: prepend the special __name__ label to the front of the label slice (prometheusremotewrite) #11674
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Required for all PRs
resolves #9365
The Thanos project recently merged thanos-io/thanos#5508 which will break every setup that uses telegraf in its current state to remote write to Thanos. All write requests will be rejected with a 409.
There's a "hidden" prerequisite that all labels in Prometheus TSDB (which Thanos also uses) need to be sorted, I couldn't find official documentation that mentions this but it has come up in other PRs, for example prometheus/prometheus#5372.
My change will always put the
__name__
as the first label. This could potentially also be wrong when labels that start with uppercase letters are used but since it was already completely broken I would like to fix this without introducing too big of a change (and why would you ever use uppercase label names?).I'm not sure if this should be mentioned in any README and I'm also not sure how we can test this since I don't see anything regarding the
__name__
label in the telegraf metrics that are used in the tests. One of the tests has a slight change in the metric ordering but that should be OK since the goal is to sort by the metric names and not by the labels themselves.