fix: ensure old namespce data to be filterred out correctly in metrics

Signed-off-by: huanggze <loganhuang@yunify.com>
This commit is contained in:
huanggze
2019-05-11 12:00:15 +08:00
parent 3d36b254b0
commit 1a9b17f98d
2 changed files with 3 additions and 7 deletions

View File

@@ -480,7 +480,7 @@ func collectWorkspaceMetric(monitoringRequest *client.MonitoringRequestParams, w
wg.Add(1)
go func(metricName string) {
queryType, params := AssembleSpecificWorkspaceMetricRequestInfo(monitoringRequest, namespaceArray, "", metricName)
queryType, params := AssembleSpecificWorkspaceMetricRequestInfo(monitoringRequest, namespaceArray, ".*", metricName)
metricsStr := client.SendMonitoringRequest(client.PrometheusEndpoint, queryType, params)
ch <- ReformatJson(metricsStr, metricName, map[string]string{ResultItemMetricResourceName: ws})
wg.Done()

View File

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