From 20e34bfe15a7567644f060c7b29cf88b2efb084c Mon Sep 17 00:00:00 2001 From: ning1875 <907974064@qq.com> Date: Tue, 27 Jul 2021 15:07:54 +0800 Subject: [PATCH] 1. tag-pair support fuzzy matching search (#747) --- backend/prome/query.go | 9 ++++++++- vos/query.go | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/prome/query.go b/backend/prome/query.go index 2158e980..1367dd88 100644 --- a/backend/prome/query.go +++ b/backend/prome/query.go @@ -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{}{} + } } } diff --git a/vos/query.go b/vos/query.go index 16b97e87..22475dde 100644 --- a/vos/query.go +++ b/vos/query.go @@ -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"` }