From 522d40fa26acc21f99b404ada10ebf5cf5c6048e Mon Sep 17 00:00:00 2001 From: bergquist Date: Thu, 6 Oct 2016 18:51:17 +0200 Subject: [PATCH] fix(influxdb): support mulitple tags --- pkg/tsdb/influxdb/response_parser.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/tsdb/influxdb/response_parser.go b/pkg/tsdb/influxdb/response_parser.go index 0d7d8d049e3..81c90e65419 100644 --- a/pkg/tsdb/influxdb/response_parser.go +++ b/pkg/tsdb/influxdb/response_parser.go @@ -3,6 +3,7 @@ package influxdb import ( "encoding/json" "fmt" + "strings" "github.com/grafana/grafana/pkg/tsdb" "gopkg.in/guregu/null.v3" @@ -45,17 +46,18 @@ func (rp *ResponseParser) parseResult(result []Row, queryResult *tsdb.QueryResul } func (rp *ResponseParser) formatName(row Row, column string) string { - tags := "" + var tags []string for k, v := range row.Tags { - tags += k + ": " + v + tags = append(tags, fmt.Sprintf("%s: %s", k, v)) } - if tags != "" { - tags = fmt.Sprintf(" { %s }", tags) + tagText := "" + if len(tags) > 0 { + tagText = fmt.Sprintf(" { %s }", strings.Join(tags, " ")) } - return fmt.Sprintf("%s.%s%s", row.Name, column, tags) + return fmt.Sprintf("%s.%s%s", row.Name, column, tagText) } func (rp *ResponseParser) parseTimepoint(k []interface{}, valuePosition int) tsdb.TimePoint {