1. tag-pair support fuzzy matching search (#747)

This commit is contained in:
ning1875 2021-07-27 15:07:54 +08:00 committed by GitHub
parent 0f63feed22
commit 20e34bfe15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -597,7 +597,14 @@ func (pd *PromeDataSource) QueryTagPairs(recv vos.CommonTagQueryParam) *vos.TagP
if i.Name == LABEL_IDENT {
labelIdents = append(labelIdents, i.Value)
}
tps[fmt.Sprintf("%s=%s", i.Name, i.Value)] = struct{}{}
if recv.Search != "" {
// 如果配置了搜索字符串则key value中任意匹配到即可
if strings.Contains(i.Name, recv.Search) || strings.Contains(i.Value, recv.Search) {
tps[fmt.Sprintf("%s=%s", i.Name, i.Value)] = struct{}{}
}
} else {
tps[fmt.Sprintf("%s=%s", i.Name, i.Value)] = struct{}{}
}
}
}

View File

@ -146,6 +146,7 @@ type CommonTagQueryParam struct {
End int64 `json:"end" description:"exclusive"`
StartInclusive time.Time `json:"-"`
EndExclusive time.Time `json:"-"`
Search string `json:"search"` // 查询标签组的时候的搜索 str可以是key 也可以是value
Limit int `json:"limit"`
}