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.

@netliomax25-code netliomax25-code force-pushed the prometheus-label-escape branch from 04a29c2 to b28505f Compare June 29, 2026 07:46
@apolukhin

Copy link
Copy Markdown
Member

LGTM

@robot-magpie

robot-magpie Bot commented Jun 29, 2026

Copy link
Copy Markdown

Many thanks for the PR! @apolukhin is now importing your pull request into our internal upstream repository.

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.

2 participants