Fix InfluxDB tag variables parsing (#46862)

* regex bug fixed

* remove unnecessary test
This commit is contained in:
Santiago 2022-03-23 21:13:17 -06:00 committed by GitHub
parent c5f295b5b3
commit a9b55f7905
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -16,7 +16,7 @@ import (
type ResponseParser struct{}
var (
legendFormat = regexp.MustCompile(`\[\[([\@\/\w-]+)(\.[\@\/\w-]+)*\]\]*|\$(\s*([\@\w-]+?))*`)
legendFormat = regexp.MustCompile(`\[\[([\@\/\w-]+)(\.[\@\/\w-]+)*\]\]*|\$([\@\w-]+?)*`)
)
func (rp *ResponseParser) Parse(buf io.ReadCloser, queries []Query) *backend.QueryDataResponse {

View File

@ -492,6 +492,16 @@ func TestInfluxdbResponseParser(t *testing.T) {
t.Errorf("Result mismatch (-want +got):\n%s", diff)
}
query = &Query{Alias: "alias $0, $1 - $2 - $3, $4: something"}
result = parser.Parse(prepare(response), addQueryToQueries(*query))
frame = result.Responses["A"]
name = "alias cpu, upc - $2 - $3, $4: something"
testFrame.Name = name
testFrame.Fields[1].Config.DisplayNameFromDS = name
if diff := cmp.Diff(testFrame, frame.Frames[0], data.FrameTestCompareOptions()...); diff != "" {
t.Errorf("Result mismatch (-want +got):\n%s", diff)
}
query = &Query{Alias: "alias $1"}
result = parser.Parse(prepare(response), addQueryToQueries(*query))
frame = result.Responses["A"]