mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 01:23:32 -06:00
feat(influxdb): add tags to serie names
This commit is contained in:
parent
b0addbd7cb
commit
87650c150b
@ -45,7 +45,17 @@ func (rp *ResponseParser) parseResult(result []Row, queryResult *tsdb.QueryResul
|
||||
}
|
||||
|
||||
func (rp *ResponseParser) formatName(row Row, column string) string {
|
||||
return fmt.Sprintf("%s.%s", row.Name, column)
|
||||
tags := ""
|
||||
|
||||
for k, v := range row.Tags {
|
||||
tags += k + ": " + v
|
||||
}
|
||||
|
||||
if tags != "" {
|
||||
tags = fmt.Sprintf(" { %s }", tags)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s.%s%s", row.Name, column, tags)
|
||||
}
|
||||
|
||||
func (rp *ResponseParser) parseTimepoint(k []interface{}, valuePosition int) tsdb.TimePoint {
|
||||
|
@ -52,8 +52,8 @@ func TestInfluxdbResponseParser(t *testing.T) {
|
||||
})
|
||||
|
||||
Convey("can format serie names", func() {
|
||||
So(result.Series[0].Name, ShouldEqual, "cpu.mean")
|
||||
So(result.Series[1].Name, ShouldEqual, "cpu.sum")
|
||||
So(result.Series[0].Name, ShouldEqual, "cpu.mean { datacenter: America }")
|
||||
So(result.Series[1].Name, ShouldEqual, "cpu.sum { datacenter: America }")
|
||||
})
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user