returnnil,fmt.Errorf("unexpected open or close brace: %s",s)
}
m,err=parse.Matcher(s)
iferr!=nil{
m,invalidErr=labels.ParseMatcher(s)
ifinvalidErr!=nil{
// The input is not valid in the old pkg/labels parser either,
// it cannot be valid input.
returnnil,invalidErr
}
// The input is valid in the old pkg/labels parser, but not the
// new matchers/parse parser.
suggestion:=m.String()
level.Warn(l).Log("msg","Alertmanager is moving to a new parser for labels and matchers, and this input is incompatible. Alertmanager has instead parsed the input using the old matchers parser as a fallback. To make this input compatible with the new parser please make sure all regular expressions and values are double-quoted. If you are still seeing this message please open an issue.","input",s,"err",err,"suggestion",suggestion)
}
returnm,nil
}
}
// fallbackMatchersParser uses the new matchers/parse parser to parse the
// matcher in the input string. If this fails it falls back to the old
// pkg/labels parser and emits a warning log line.
level.Debug(l).Log("msg","Parsing with UTF-8 matchers parser, with fallback to classic matchers parser","input",s)
m,err=parse.Matchers(s)
iferr!=nil{
m,invalidErr=labels.ParseMatchers(s)
ifinvalidErr!=nil{
// The input is not valid in the old pkg/labels parser either,
// it cannot be valid input.
returnnil,invalidErr
}
varsbstrings.Builder
fori,n:=rangem{
sb.WriteString(n.String())
ifi<len(m)-1{
sb.WriteRune(',')
}
}
suggestion:=sb.String()
// The input is valid in the old pkg/labels parser, but not the
// new matchers/parse parser.
level.Warn(l).Log("msg","Alertmanager is moving to a new parser for labels and matchers, and this input is incompatible. Alertmanager has instead parsed the input using the old matchers parser as a fallback. To make this input compatible with the new parser please make sure all regular expressions and values are double-quoted. If you are still seeing this message please open an issue.","input",s,"err",err,"suggestion",suggestion)