Repository navigation
Base64-encode . and .. in Pushgateway job and grouping values - #343
Open
sarankumar1325 wants to merge 1 commit into
Open
sarankumar1325 wants to merge 1 commit into
sarankumar1325 wants to merge 1 commit into
Conversation
A job name or grouping key value of `.` or `..` was put into the URL path as-is. Those are dot segments, so the Pushgateway answers with a 307 redirect to the cleaned path and the push fails with HttpRedirectError (proxies may also rewrite the path to a different group). The Pushgateway docs ask for base64 encoding in this case, the same way client_golang does it. Encode these values with `@base64`, like values containing `/`. Signed-off-by: sarankumar1325 <120080287+sarankumar1325@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Prometheus::Client::Pushputs a job name or grouping key value of.or..into the URL path unchanged. Those are dot segments. The Pushgateway answers with a307to the cleaned path, so the push fails withHttpRedirectError. A proxy that normalises the path can also send it to a different group. The Pushgateway README asks for base64 encoding in this case, and client_golang already does this (encodeComponentcheckss == "." || s == "..").This PR base64-encodes
.and..the same way values containing/are already encoded. Other values that just contain dots (for example...ora.b) are unchanged.Before (against a local pushgateway v1.x):
After: the push succeeds and the gateway stores the group
{job="j", instance=".."}.Tests: two new cases in
spec/prometheus/client/push_spec.rb(job and grouping values). Both fail without the fix. The fullbundle exec rspecrun passes: 200 examples, 0 failures.I used an AI assistant for this change. I reproduced the bug against a real Pushgateway and reviewed and tested the change myself.