fix: ensure namespces to be filterred correctly in workspace metrics

Signed-off-by: huanggze <loganhuang@yunify.com>
This commit is contained in:
huanggze
2019-05-10 15:23:14 +08:00
parent 7bf044a766
commit 3d36b254b0
4 changed files with 67 additions and 42 deletions

View File

@@ -116,11 +116,19 @@ func MakeAllWorkspacesPromQL(metricsName, nsFilter string) string {
return promql
}
func MakeSpecificWorkspacePromQL(metricsName, nsFilter string) string {
func MakeSpecificWorkspacePromQL(metricsName, nsFilter string, workspace string) string {
var promql = RulePromQLTmplMap[metricsName]
nsFilter = "=~\"" + nsFilter + "\""
if workspace == "" {
workspace = "=~\".*\""
} else {
workspace = "=\"" + workspace + "\""
}
promql = strings.Replace(promql, "$1", nsFilter, -1)
promql = strings.Replace(promql, "$2", workspace, -1)
return promql
}