Browse Source

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
Floyd May 6 years ago
parent
commit
33d1d427bc
2 changed files with 12 additions and 2 deletions
  1. 1 1
      pkg/tsdb/influxdb/response_parser.go
  2. 11 1
      pkg/tsdb/influxdb/response_parser_test.go

+ 1 - 1
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 {

+ 11 - 1
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")
+				})
 			})
 		})
 	})