use LabelNam.IsValid() instead of LabelNameRE and MatchString instead of Match

This commit is contained in:
Matti Savolainen 2016-10-19 16:30:52 +03:00
parent ec6524ce74
commit aabf4a419b
1 changed files with 2 additions and 2 deletions

View File

@ -1015,10 +1015,10 @@ func (c *RelabelConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
if (c.Action == RelabelReplace || c.Action == RelabelHashMod) && c.TargetLabel == "" {
return fmt.Errorf("relabel configuration for %s action requires 'target_label' value", c.Action)
}
if c.Action == RelabelReplace && !relabelTarget.Match([]byte(c.TargetLabel)) {
if c.Action == RelabelReplace && !relabelTarget.MatchString(c.TargetLabel) {
return fmt.Errorf("%q is invalid 'target_label' for %s action", c.TargetLabel, c.Action)
}
if c.Action == RelabelHashMod && !model.LabelNameRE.Match([]byte(c.TargetLabel)) {
if c.Action == RelabelHashMod && !model.LabelName(c.TargetLabel).IsValid() {
return fmt.Errorf("%q is invalid 'target_label' for %s action", c.TargetLabel, c.Action)
}
return nil