mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2024-11-26 17:21:01 +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.
|
// Check that label is correct.
|
||||||
for k, v := range currentMapping.Labels {
|
for k, v := range currentMapping.Labels {
|
||||||
label := fmt.Sprintf("%s=%q", k, v)
|
if !metricNameRE.MatchString(k) {
|
||||||
if len(labelLineRE.FindStringSubmatch(label)) != 3 {
|
return fmt.Errorf("invalid label key: %s", k)
|
||||||
return fmt.Errorf("invalid label: %s: %s", k, v)
|
|
||||||
}
|
}
|
||||||
if k == "name" && !metricNameRE.MatchString(v) {
|
if k == "name" && !metricNameRE.MatchString(v) {
|
||||||
return fmt.Errorf("metric name '%s' doesn't match regex '%s'", v, metricNameRE)
|
return fmt.Errorf("metric name '%s' doesn't match regex '%s'", v, metricNameRE)
|
||||||
|
|
Loading…
Reference in a new issue