diff --git a/cli/silence_query.go b/cli/silence_query.go index 43bd7586..375ff3f4 100644 --- a/cli/silence_query.go +++ b/cli/silence_query.go @@ -94,9 +94,9 @@ func fetchSilences(filter string) ([]types.Silence, error) { func query(element *kingpin.ParseElement, ctx *kingpin.ParseContext) error { var filterString = "" if len(*silenceQuery) == 1 { - // If we only have one argument then it's possible that the user wants me to assume alertname= - // Attempt to use the parser to pare the argument - // If the parser fails then we likely don't have a (=|=~|!=|!~) so lets prepend `alertname=` to the front + // If the parser fails then we likely don't have a (=|=~|!=|!~) so lets + // assume that the user wants alertname= and prepend `alertname=` + // to the front. _, err := parse.Matcher((*silenceQuery)[0]) if err != nil { filterString = fmt.Sprintf("{alertname=%s}", (*silenceQuery)[0]) diff --git a/pkg/parse/parse.go b/pkg/parse/parse.go index 33ea22c0..f5401370 100644 --- a/pkg/parse/parse.go +++ b/pkg/parse/parse.go @@ -53,7 +53,7 @@ func Matcher(s string) (*labels.Matcher, error) { func Input(s string) (name, value string, matchType labels.MatchType, err error) { ms := re.FindStringSubmatch(s) if len(ms) < 4 { - return "", "", labels.MatchEqual, fmt.Errorf("bad matcher format") + return "", "", labels.MatchEqual, fmt.Errorf("bad matcher format: %s", s) } var prs bool