Fix spaces in grouping key values for push_to_gateway#1156
Open
veeceey wants to merge 1 commit intoprometheus:masterfrom
Open
Fix spaces in grouping key values for push_to_gateway#1156veeceey wants to merge 1 commit intoprometheus:masterfrom
veeceey wants to merge 1 commit intoprometheus:masterfrom
Conversation
Use base64 encoding for grouping key values containing spaces, similar to how values with slashes are handled. This prevents spaces from being converted to '+' signs by quote_plus(). Fixes prometheus#1064 Signed-off-by: Varun Chawla <varun_6april@hotmail.com>
3f4de1b to
ff09e4a
Compare
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.
Summary
Fixes the handling of spaces in grouping key values when using
push_to_gateway. Previously, spaces were converted to+signs, which resulted in incorrect label values in Prometheus Pushgateway.Problem
When pushing metrics with grouping keys containing spaces, the
quote_plusfunction converts spaces to+signs in the URL. The Pushgateway interprets these as literal+characters rather than spaces.Example:
Before fix: Label value becomes
value+with+spacesAfter fix: Label value is correctly
value with spacesSolution
Use base64 encoding for grouping key values containing spaces, similar to how values with slashes are already handled. This ensures the value is transmitted accurately to the Pushgateway.
Changes
_escape_grouping_key()to check for spaces in addition to slashestest_push_with_groupingkey_with_spaces()to verify the fixTest Plan
test_push_with_groupingkey_with_spacesthat verifies:@base64suffixManual verification:
The fix can be verified by running the reproduction script from the issue:
After this change, the Pushgateway will correctly show
label="value with spaces"instead oflabel="value+with+spaces".Fixes #1064