未验证 提交 39de0892 编写于 作者: ning1875's avatar ning1875 提交者: GitHub

fix: query index api

上级 36ec4e09
......@@ -56,13 +56,8 @@ func convertToPromql(recv *commonQueryObj) string {
labelStrSlice = append(labelStrSlice, metricName)
}
// 匹配ident=~"k1.*|k2.*"
for _, i := range recv.Idents {
if i != "" {
labelIdent += fmt.Sprintf(`.*%s.*|`, i)
}
}
labelIdent = strings.TrimRight(labelIdent, "|")
// 匹配ident=~"k1|k2"
labelIdent = strings.Join(recv.Idents, "|")
if labelIdent != "" {
labelStrSlice = append(labelStrSlice, fmt.Sprintf(`ident=~"%s"`, labelIdent))
}
......@@ -83,10 +78,7 @@ func convertToPromql(recv *commonQueryObj) string {
}
for _, s := range labelStrSlice {
qlStr += fmt.Sprintf(`%s,`, s)
}
qlStr = strings.TrimRight(qlStr, ",")
qlStr = strings.Join(labelStrSlice, ",")
qlStrFinal = fmt.Sprintf(`{%s}`, qlStr)
logger.Debugf("[convertToPromql][type=queryLabel][recv:%+v][qlStrFinal:%s]", recv, qlStrFinal)
......@@ -108,13 +100,8 @@ func convertToPromqlForQueryData(recv *commonQueryObj) string {
labelStrSlice = append(labelStrSlice, metricName)
}
// 匹配ident=~"k1.*|k2.*"
for _, i := range recv.Idents {
if i != "" {
labelIdent += fmt.Sprintf(`%s|`, i)
}
}
labelIdent = strings.TrimRight(labelIdent, "|")
// 匹配ident=~"k1|k2"
labelIdent = strings.Join(recv.Idents, "|")
if labelIdent != "" {
labelStrSlice = append(labelStrSlice, fmt.Sprintf(`ident=~"%s"`, labelIdent))
}
......@@ -135,10 +122,7 @@ func convertToPromqlForQueryData(recv *commonQueryObj) string {
}
for _, s := range labelStrSlice {
qlStr += fmt.Sprintf(`%s,`, s)
}
qlStr = strings.TrimRight(qlStr, ",")
qlStr = strings.Join(labelStrSlice, ",")
qlStrFinal = fmt.Sprintf(`{%s}`, qlStr)
logger.Debugf("[convertToPromql][type=queryData][recv:%+v][qlStrFinal:%s]", recv, qlStrFinal)
......
......@@ -106,7 +106,7 @@ func GetTagValues(c *gin.Context) {
return
}
if recv.TagKey == "" {
renderMessage(c, errors.New("missing tagkey"))
renderMessage(c, errors.New("missing tag_key"))
return
}
resp := dataSource.QueryTagValues(recv)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册