Skip to content

Commit

Permalink
tsdb 查询 tag value 支持 all
Browse files Browse the repository at this point in the history
  • Loading branch information
吴迎松 committed Dec 18, 2018
1 parent 0e0a194 commit 444e7c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions common/tsdb/kairosdb.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tsdb

import (
"errors"
"fmt"
"strconv"
"strings"
Expand Down Expand Up @@ -35,6 +36,9 @@ func (k *KairosDbClient) newQueryBuilder(start, end, rawTags, aggregator, metric
if _, ok := tags[tagKV[0]]; !ok {
tagks = append(tagks, tagKV[0])
}
if tagKV[1] == "all" {
continue
}
tags[tagKV[0]] = append(tags[tagKV[0]], strings.Split(tagKV[1], "|")...)
}
}
Expand All @@ -59,6 +63,10 @@ func (k *KairosDbClient) Query(start, end, rawTags, aggregator, metric string, i
if err != nil {
return
}
errs := queryResp.GetErrors()
if len(errs) > 0 {
err = errors.New(strings.Join(errs, "|"))
}
if len(queryResp.QueriesArr) > 0 {
for _, r := range queryResp.QueriesArr[0].ResultsArr {
result := new(Result)
Expand Down
3 changes: 3 additions & 0 deletions common/tsdb/opentsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ func (c *OpenTsdbClient) newQueryParams(start, end, rawTags, aggregator, metric
tagsPairs := strings.Split(rawTags, ",")
for _, tagPair := range tagsPairs {
tagKV := strings.Split(tagPair, "=")
if tagKV[1] == "all" {
tagKV[1] = "*"
}
tags[tagKV[0]] = tagKV[1]
}
}
Expand Down

0 comments on commit 444e7c3

Please sign in to comment.