From 194039c429d6061b5fe08ba99954996a5809bf7e Mon Sep 17 00:00:00 2001 From: ismail simsek Date: Tue, 14 May 2024 09:53:18 +0200 Subject: [PATCH] InfluxDB: Update alias regex pattern (#87713) * use frontend mode alias regex * remove comment --- pkg/tsdb/influxdb/influxql/util/util.go | 2 +- pkg/tsdb/influxdb/influxql/util/util_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/tsdb/influxdb/influxql/util/util.go b/pkg/tsdb/influxdb/influxql/util/util.go index b0179f3b2b5..33ddfdff845 100644 --- a/pkg/tsdb/influxdb/influxql/util/util.go +++ b/pkg/tsdb/influxdb/influxql/util/util.go @@ -15,7 +15,7 @@ import ( ) var ( - legendFormat = regexp.MustCompile(`\[\[([\@\/\w-]+)(\.[\@\/\w-]+)*\]\]*|\$([\@\w]+?)*`) + legendFormat = regexp.MustCompile(`\$(\w+)|\[\[([\s\S]+?)\]\]`) ) const ( diff --git a/pkg/tsdb/influxdb/influxql/util/util_test.go b/pkg/tsdb/influxdb/influxql/util/util_test.go index 12809575a82..d3e807fb7d7 100644 --- a/pkg/tsdb/influxdb/influxql/util/util_test.go +++ b/pkg/tsdb/influxdb/influxql/util/util_test.go @@ -43,6 +43,7 @@ func TestFormatFrameName(t *testing.T) { {name: "[[col]] column alias", rowName: "rowName", column: "colName", tags: map[string]string{"key": "value"}, query: models.Query{Alias: "[[col]]", ResultFormat: "time_series"}, expected: "colName"}, {name: "$col column alias", rowName: "rowName", column: "colName", tags: map[string]string{"key": "value"}, query: models.Query{Alias: "$col", ResultFormat: "time_series"}, expected: "colName"}, {name: "[[tag_key]] tag alias", rowName: "rowName", column: "colName", tags: map[string]string{"key": "value"}, query: models.Query{Alias: "[[tag_key]]", ResultFormat: "time_series"}, expected: "value"}, + {name: "[[tag_key]] tag alias with space in tag", rowName: "rowName", column: "colName", tags: map[string]string{"ke y": "value"}, query: models.Query{Alias: "[[tag_ke y]]", ResultFormat: "time_series"}, expected: "value"}, {name: "$tag_key tag alias", rowName: "rowName", column: "colName", tags: map[string]string{"key": "value"}, query: models.Query{Alias: "$tag_key", ResultFormat: "time_series"}, expected: "value"}, {name: "[[m]] with additional text", rowName: "rowName", column: "colName", tags: map[string]string{"key": "value"}, query: models.Query{Alias: "[[m]] - something", ResultFormat: "time_series"}, expected: "rowName - something"}, {name: "$m with additional text", rowName: "rowName", column: "colName", tags: map[string]string{"key": "value"}, query: models.Query{Alias: "$m - something", ResultFormat: "time_series"}, expected: "rowName - something"},