Skip to content

Commit

Permalink
[v10.2.x] InfluxDB: Fix parsing multiple tags on backend mode (#77382)
Browse files Browse the repository at this point in the history
InfluxDB: Fix parsing multiple tags on backend mode (#77340)

* Multiple tags separated by comma in the result

* A non-flaky unit test

(cherry picked from commit 6b13064)
  • Loading branch information
itsmylife committed Oct 30, 2023
1 parent 717a936 commit 1c11ba7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/tsdb/influxdb/influxql/response_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ func buildFrameNameFromQuery(row models.Row, column string, frameName []byte, re
first := true
for k, v := range row.Tags {
if !first {
frameName = append(frameName, ',')
frameName = append(frameName, ' ')
} else {
first = false
Expand Down
40 changes: 40 additions & 0 deletions pkg/tsdb/influxdb/influxql/response_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,46 @@ func TestInfluxdbResponseParser(t *testing.T) {
assert.Equal(t, "alias logins.count", result.Frames[1].Name)
})

t.Run("Influxdb response parser when multiple measurement in response", func(t *testing.T) {
response := `
{
"results": [
{
"series": [
{
"name": "cpu.upc",
"columns": ["time","mean"],
"tags": {
"datacenter": "America",
"cluster-name": "Cluster"
},
"values": [
[111,222]
]
},
{
"name": "logins.count",
"columns": ["time","mean"],
"tags": {
"datacenter": "America",
"cluster-name": "Cluster"
},
"values": [
[111,222]
]
}
]
}
]
}
`

query := models.Query{}
result := ResponseParse(prepare(response), 200, generateQuery(query))
assert.True(t, strings.Contains(result.Frames[0].Name, ","))
assert.True(t, strings.Contains(result.Frames[1].Name, ","))
})

t.Run("Influxdb response parser with alias", func(t *testing.T) {
response := `
{
Expand Down

0 comments on commit 1c11ba7

Please sign in to comment.