Skip to content

Commit

Permalink
Add brackets to sanitize list to prevent invalide metric name generation
Browse files Browse the repository at this point in the history
  • Loading branch information
nixargh committed Nov 14, 2024
1 parent 2068660 commit b95d70e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/promutil/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ var replacer = strings.NewReplacer(
"@", "_",
"<", "_",
">", "_",
"(", "_",
")", "_",
"%", "_percent",
)

Expand Down Expand Up @@ -190,7 +192,7 @@ func sanitize(text string) string {
b := []byte(text)
for i := 0; i < len(b); i++ {
switch b[i] {
case ' ', ',', '\t', '/', '\\', '.', '-', ':', '=', '@', '<', '>':
case ' ', ',', '\t', '/', '\\', '.', '-', ':', '=', '@', '<', '>', '(', ')':
b[i] = '_'
}
}
Expand Down

0 comments on commit b95d70e

Please sign in to comment.