fix: tagkv api get redundant values

This commit is contained in:
710leo 2020-03-24 11:15:00 +08:00
parent 50bb36f2ed
commit 4e5f7a56da
3 changed files with 6 additions and 5 deletions

View File

@ -30,8 +30,9 @@ func (t *TagkvIndex) GetTagkv() []*TagPair {
t.RLock()
defer t.RUnlock()
tagkvs := []*TagPair{}
var vs []string
for k, vm := range t.Tagkv {
var vs []string
for v, _ := range vm {
vs = append(vs, v)
}
@ -50,8 +51,8 @@ func (t *TagkvIndex) GetTagkvMap() map[string][]string {
defer t.RUnlock()
tagkvs := make(map[string][]string)
var vs []string
for k, vm := range t.Tagkv {
var vs []string
for v, _ := range vm {
vs = append(vs, v)
}

View File

@ -93,9 +93,8 @@ func GetTagPairs(c *gin.Context) {
resp := []*IndexTagkvResp{}
tagkvFilter := make(map[string]map[string]struct{})
for _, metric := range recv.Metrics {
tagkvFilter := make(map[string]map[string]struct{})
tagkvs := []*cache.TagPair{}
for _, endpoint := range recv.Endpoints {
@ -107,6 +106,7 @@ func GetTagPairs(c *gin.Context) {
}
tagkvMap := metricIndex.TagkvMap.GetTagkvMap()
for tagk, tagvs := range tagkvMap {
tagvFilter, exists := tagkvFilter[tagk]
if !exists {

View File

@ -18,7 +18,7 @@ func Config(r *gin.Engine) {
sys.GET("/alive-judges", judges)
sys.POST("/push", PushData)
sys.POST("/data", QueryDataForJudge)
sys.POST("/data", QueryData)
sys.POST("/data/ui", QueryDataForUI)
}