Skip to content

fix prometheus: escape backslash and newline in label values#1268

Open
netliomax25-code wants to merge 1 commit into
userver-framework:developfrom
netliomax25-code:prometheus-label-escape
Open

fix prometheus: escape backslash and newline in label values#1268
netliomax25-code wants to merge 1 commit into
userver-framework:developfrom
netliomax25-code:prometheus-label-escape

Conversation

@netliomax25-code

Copy link
Copy Markdown
Contributor
  1. DumpLabelsRaw escapes only " (to ') in Prometheus label values, leaving backslash and line feeds raw.
  2. A value ending in \ then escapes the closing quote so the rest of the line is pulled into the value, and an embedded line feed starts a new sample line.

Added AppendEscapedLabelValue to double \ and write line feeds as \n, matching how the Graphite and Solomon writers already neutralize these characters. Covered both cases with a regression test.

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.

1 participant