Skip to content

fix(metrics): sanitize label names in OpenMetrics output#59255

Open
moktamd wants to merge 1 commit intonextcloud:masterfrom
moktamd:fix/metrics-escape-label-names
Open

fix(metrics): sanitize label names in OpenMetrics output#59255
moktamd wants to merge 1 commit intonextcloud:masterfrom
moktamd:fix/metrics-escape-label-names

Conversation

@moktamd
Copy link
Copy Markdown

@moktamd moktamd commented Mar 27, 2026

Fixes #59247

Apps with hyphens in their name (e.g. hide-photos) produce invalid OpenMetrics label names, causing Prometheus to reject the entire scrape. Label names must match [a-zA-Z_][a-zA-Z0-9_]* per the spec.

Sanitizes label names in formatLabels() by replacing non-alphanumeric characters with underscores, so hide-photos becomes hide_photos.

Replace non-alphanumeric characters (e.g. hyphens) in metric label
names with underscores so the output conforms to the OpenMetrics
specification. Apps like 'hide-photos' produced invalid label names
that caused Prometheus ingestion failures.
@moktamd moktamd requested a review from a team as a code owner March 27, 2026 14:17
@moktamd moktamd requested review from ArtificialOwl, come-nc, leftybournes and salmart-dev and removed request for a team March 27, 2026 14:18
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.

[Bug]: /metrics endpoint does not escape hyphens

1 participant