feat(influxdb): add tags to serie names

This commit is contained in:
bergquist 2016-10-06 18:47:59 +02:00
parent b0addbd7cb
commit 87650c150b
2 changed files with 13 additions and 3 deletions

View File

@ -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 {

View File

@ -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 }")
})
})
}