Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/promutil/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ func PromStringTag(text string, labelsSnakeCase bool) (bool, string) {

// sanitize replaces some invalid chars with an underscore
func sanitize(text string) string {

// metrics starting with a digit violate the prometheus metric naming convention, so we add an underscore
if len(text) > 0 && text[0] >= '0' && text[0] <= '9' {
text = "_" + text
}

if strings.ContainsAny(text, "“%") {
// fallback to the replacer for complex cases:
// - '“' is non-ascii rune
Expand Down