From 33d1d427bc8e472f3cef9c04bc9d7de3841ba0dd Mon Sep 17 00:00:00 2001 From: Floyd May Date: Wed, 27 Mar 2019 11:13:12 -0500 Subject: [PATCH] InfluxDB: Fix tag names with periods in alerting (#16255) Updates regex to match tag names with periods when generating series names in alerting evaluation (backend). Fixes #9148 --- pkg/tsdb/influxdb/response_parser.go | 2 +- pkg/tsdb/influxdb/response_parser_test.go | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/tsdb/influxdb/response_parser.go b/pkg/tsdb/influxdb/response_parser.go index 8de8dcbb464..d4930a00585 100644 --- a/pkg/tsdb/influxdb/response_parser.go +++ b/pkg/tsdb/influxdb/response_parser.go @@ -18,7 +18,7 @@ var ( ) func init() { - legendFormat = regexp.MustCompile(`\[\[(\w+?)*\]\]*|\$\s*(\w+?)*`) + legendFormat = regexp.MustCompile(`\[\[(\w+)(\.\w+)*\]\]*|\$\s*(\w+?)*`) } func (rp *ResponseParser) Parse(response *Response, query *Query) *tsdb.QueryResult { diff --git a/pkg/tsdb/influxdb/response_parser_test.go b/pkg/tsdb/influxdb/response_parser_test.go index d8ec6e145c7..43b96657e3e 100644 --- a/pkg/tsdb/influxdb/response_parser_test.go +++ b/pkg/tsdb/influxdb/response_parser_test.go @@ -75,7 +75,10 @@ func TestInfluxdbResponseParser(t *testing.T) { { Name: "cpu.upc", Columns: []string{"time", "mean", "sum"}, - Tags: map[string]string{"datacenter": "America"}, + Tags: map[string]string{ + "datacenter": "America", + "dc.region.name": "Northeast", + }, Values: [][]interface{}{ {json.Number("111"), json.Number("222"), json.Number("333")}, }, @@ -159,6 +162,13 @@ func TestInfluxdbResponseParser(t *testing.T) { So(result.Series[0].Name, ShouldEqual, "alias America") }) + + Convey("tag alias with periods", func() { + query := &Query{Alias: "alias [[tag_dc.region.name]]"} + result := parser.Parse(response, query) + + So(result.Series[0].Name, ShouldEqual, "alias Northeast") + }) }) }) })