From 430104aaacf584f49cadb413c25ec1c7c7c74d72 Mon Sep 17 00:00:00 2001 From: bergquist Date: Wed, 16 Nov 2016 10:03:22 +0100 Subject: [PATCH] feat(mqe): add support for wildcard series --- pkg/tsdb/mqe/types.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/pkg/tsdb/mqe/types.go b/pkg/tsdb/mqe/types.go index de5ff2fc8e9..34e643adc8f 100644 --- a/pkg/tsdb/mqe/types.go +++ b/pkg/tsdb/mqe/types.go @@ -7,6 +7,7 @@ import ( "regexp" + "github.com/grafana/grafana/pkg/log" "github.com/grafana/grafana/pkg/tsdb" ) @@ -31,7 +32,6 @@ var ( containsWildcardPattern *regexp.Regexp = regexp.MustCompile(`\*`) ) -//`os.disk.sda.io_time` where host in ('staples-lab-1') from 1479197578194 to 1479219178194 func (q *MQEQuery) Build(availableSeries []string) ([]string, error) { var queries []string where := q.buildWhereClause() @@ -44,13 +44,20 @@ func (q *MQEQuery) Build(availableSeries []string) ([]string, error) { continue } - /* - for _, a := range availableSeries { - if match { - metrics = append(metrics, a) - } + m := strings.Replace(v.Metric, "*", ".*", -1) + mp, err := regexp.Compile(m) + + if err != nil { + log.Error2("failed to compile regex for ", "metric", m) + continue + } + + //TODO: this lookup should be cached + for _, a := range availableSeries { + if mp.Match([]byte(a)) { + metrics = append(metrics, a) } - */ + } } for _, metric := range metrics {