diff --git a/pkg/tsdb/influxdb/influxql/response_parser.go b/pkg/tsdb/influxdb/influxql/response_parser.go index c8824163823..390008702c7 100644 --- a/pkg/tsdb/influxdb/influxql/response_parser.go +++ b/pkg/tsdb/influxdb/influxql/response_parser.go @@ -258,6 +258,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 diff --git a/pkg/tsdb/influxdb/influxql/response_parser_test.go b/pkg/tsdb/influxdb/influxql/response_parser_test.go index 0b68b619d61..78281e56d76 100644 --- a/pkg/tsdb/influxdb/influxql/response_parser_test.go +++ b/pkg/tsdb/influxdb/influxql/response_parser_test.go @@ -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 := ` {