Files
Carles GarciaandGitHub 80d0c5c336 config: validate more fields and duplicate labels in the user API (#6008)
* config: validate more fields and duplicate labels in the user API

- detect duplicate labels after sanitization in span-metrics and service-graphs dimensions
- add validation for dimension mappings
- add validation for host-info metric name

* add changelog entry
2025-12-01 09:26:36 +01:00

23 lines
481 B
Go

package validation
import (
"github.com/prometheus/prometheus/util/strutil"
)
type SanitizeFn func(string) string
func SanitizeLabelNameWithCollisions(name string, dimensions map[string]struct{}, sanitizeFn SanitizeFn) string {
sanitized := sanitizeFn(name)
// check if same label as intrinsics
if _, ok := dimensions[sanitized]; ok {
return "__" + sanitized
}
return sanitized
}
func SanitizeLabelName(name string) string {
return strutil.SanitizeLabelName(name)
}