InfluxDB: Update alias regex pattern (#87713)

* use frontend mode alias regex

* remove comment
This commit is contained in:
ismail simsek 2024-05-14 09:53:18 +02:00 committed by GitHub
parent bbb4323f7e
commit 194039c429
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View File

@ -15,7 +15,7 @@ import (
)
var (
legendFormat = regexp.MustCompile(`\[\[([\@\/\w-]+)(\.[\@\/\w-]+)*\]\]*|\$([\@\w]+?)*`)
legendFormat = regexp.MustCompile(`\$(\w+)|\[\[([\s\S]+?)\]\]`)
)
const (

View File

@ -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"},