Like Prometheus, but for logs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
loki/pkg/logql/matchers.go

25 lines
568 B

package logql
import (
"github.com/pkg/errors"
"github.com/prometheus/prometheus/model/labels"
"github.com/grafana/loki/pkg/logql/syntax"
)
// Match extracts and parses multiple matcher groups from a slice of strings
func Match(xs []string) ([][]*labels.Matcher, error) {
groups := make([][]*labels.Matcher, 0, len(xs))
for _, x := range xs {
ms, err := syntax.ParseMatchers(x)
if err != nil {
return nil, err
}
if len(ms) == 0 {
return nil, errors.Errorf("0 matchers in group: %s", x)
}
groups = append(groups, ms)
}
return groups, nil
}