Skip to content
Open
Changes from 2 commits
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
7 changes: 7 additions & 0 deletions pkg/promutil/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package promutil

import (
"regexp"
"strings"
"time"

Expand Down Expand Up @@ -194,6 +195,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 matched, _ := regexp.MatchString(`^\d`, text); matched {
text = "_" + text
}

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