Skip to content

Commit 444e7c3

Browse files
author
吴迎松
committed
tsdb 查询 tag value 支持 all
1 parent 0e0a194 commit 444e7c3

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

common/tsdb/kairosdb.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package tsdb
22

33
import (
4+
"errors"
45
"fmt"
56
"strconv"
67
"strings"
@@ -35,6 +36,9 @@ func (k *KairosDbClient) newQueryBuilder(start, end, rawTags, aggregator, metric
3536
if _, ok := tags[tagKV[0]]; !ok {
3637
tagks = append(tagks, tagKV[0])
3738
}
39+
if tagKV[1] == "all" {
40+
continue
41+
}
3842
tags[tagKV[0]] = append(tags[tagKV[0]], strings.Split(tagKV[1], "|")...)
3943
}
4044
}
@@ -59,6 +63,10 @@ func (k *KairosDbClient) Query(start, end, rawTags, aggregator, metric string, i
5963
if err != nil {
6064
return
6165
}
66+
errs := queryResp.GetErrors()
67+
if len(errs) > 0 {
68+
err = errors.New(strings.Join(errs, "|"))
69+
}
6270
if len(queryResp.QueriesArr) > 0 {
6371
for _, r := range queryResp.QueriesArr[0].ResultsArr {
6472
result := new(Result)

common/tsdb/opentsdb.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ func (c *OpenTsdbClient) newQueryParams(start, end, rawTags, aggregator, metric
8181
tagsPairs := strings.Split(rawTags, ",")
8282
for _, tagPair := range tagsPairs {
8383
tagKV := strings.Split(tagPair, "=")
84+
if tagKV[1] == "all" {
85+
tagKV[1] = "*"
86+
}
8487
tags[tagKV[0]] = tagKV[1]
8588
}
8689
}

0 commit comments

Comments
 (0)