Skip to content

Commit 24a3a10

Browse files
committed
feat(influxdb): add alias to query
1 parent 029e52f commit 24a3a10

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

pkg/tsdb/influxdb/model_parser.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ func (qp *InfluxdbQueryParser) Parse(model *simplejson.Json, dsInfo *tsdb.DataSo
1313
policy := model.Get("policy").MustString("default")
1414
rawQuery := model.Get("query").MustString("")
1515
interval := model.Get("interval").MustString("")
16+
alias := model.Get("alias").MustString("")
1617

1718
measurement := model.Get("measurement").MustString("")
1819

@@ -52,6 +53,7 @@ func (qp *InfluxdbQueryParser) Parse(model *simplejson.Json, dsInfo *tsdb.DataSo
5253
Selects: selects,
5354
RawQuery: rawQuery,
5455
Interval: interval,
56+
Alias: alias,
5557
}, nil
5658
}
5759

pkg/tsdb/influxdb/model_parser_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func TestInfluxdbQueryParser(t *testing.T) {
9090
}
9191
]
9292
],
93+
"alias": "serie alias",
9394
"tags": [
9495
{
9596
"key": "datacenter",
@@ -115,6 +116,7 @@ func TestInfluxdbQueryParser(t *testing.T) {
115116
So(len(res.Selects), ShouldEqual, 3)
116117
So(len(res.Tags), ShouldEqual, 2)
117118
So(res.Interval, ShouldEqual, ">20s")
119+
So(res.Alias, ShouldEqual, "serie alias")
118120
})
119121

120122
Convey("can part raw query json model", func() {

pkg/tsdb/influxdb/models.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ type Query struct {
88
GroupBy []*QueryPart
99
Selects []*Select
1010
RawQuery string
11+
Alias string
1112

1213
Interval string
1314
}

0 commit comments

Comments
 (0)