mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2024-11-22 23:41:00 +00:00
simplify metric label key validation
This commit is contained in:
parent
c339cc66ac
commit
9c1cde63be
1 changed files with 2 additions and 3 deletions
|
@ -145,9 +145,8 @@ func (m *metricMapper) initFromYAMLString(fileContents string) error {
|
|||
|
||||
// Check that label is correct.
|
||||
for k, v := range currentMapping.Labels {
|
||||
label := fmt.Sprintf("%s=%q", k, v)
|
||||
if len(labelLineRE.FindStringSubmatch(label)) != 3 {
|
||||
return fmt.Errorf("invalid label: %s: %s", k, v)
|
||||
if !metricNameRE.MatchString(k) {
|
||||
return fmt.Errorf("invalid label key: %s", k)
|
||||
}
|
||||
if k == "name" && !metricNameRE.MatchString(v) {
|
||||
return fmt.Errorf("metric name '%s' doesn't match regex '%s'", v, metricNameRE)
|
||||
|
|
Loading…
Reference in a new issue