Commit 33d1d427 by Floyd May Committed by Marcus Efraimsson

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
parent 00a07c85
......@@ -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 {
......
......@@ -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")
})
})
})
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment