From fca6a978862d2a13bdbaac151cbbbd33de30deb0 Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Thu, 13 Apr 2023 11:37:30 +0800 Subject: [PATCH] fix(monitor): wrong tag filter when get metric measurement --- pkg/monitor/models/datasource.go | 2 +- pkg/monitor/models/unifiedmonitor.go | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/monitor/models/datasource.go b/pkg/monitor/models/datasource.go index 3757497ffc..8ff58f81f6 100644 --- a/pkg/monitor/models/datasource.go +++ b/pkg/monitor/models/datasource.go @@ -658,7 +658,7 @@ func (self *SDataSourceManager) filterRtnTags(output *monitor.InfluxMeasurement) } for _, tag := range []string{"source", "status", hostconsts.TELEGRAF_TAG_KEY_HOST_TYPE, hostconsts.TELEGRAF_TAG_KEY_RES_TYPE, "is_vm", "os_type", hostconsts.TELEGRAF_TAG_KEY_PLATFORM, - hostconsts.TELEGRAF_TAG_KEY_HYPERVISOR, "domain_name", "region"} { + hostconsts.TELEGRAF_TAG_KEY_HYPERVISOR, "domain_name", "region", "ips", "vip", "vip_eip", "eip", "eip_mode"} { if _, ok := output.TagValue[tag]; ok { delete(output.TagValue, tag) } diff --git a/pkg/monitor/models/unifiedmonitor.go b/pkg/monitor/models/unifiedmonitor.go index bc89f91a96..2d5ea6d232 100644 --- a/pkg/monitor/models/unifiedmonitor.go +++ b/pkg/monitor/models/unifiedmonitor.go @@ -121,7 +121,6 @@ func filterByScope(ctx context.Context, userCred mcclient.TokenCredential, scope projectId = userCred.GetProjectId() } return getProjectIdFilterByProject(projectId) - } } @@ -159,12 +158,11 @@ func getProjectIdsFilterByDomain(domainId string) (string, error) { //} //buffer.WriteString(" )") //return buffer.String(), nil - return fmt.Sprintf(`"%s" =~ /%s/`, "domain_id", domainId), nil - + return fmt.Sprintf(`%s =~ /%s/`, "domain_id", domainId), nil } func getProjectIdFilterByProject(projectId string) (string, error) { - return fmt.Sprintf(`"%s" =~ /%s/`, "tenant_id", projectId), nil + return fmt.Sprintf(`%s =~ /%s/`, "tenant_id", projectId), nil } func (self *SUnifiedMonitorManager) GetPropertyMetricMeasurement(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) (jsonutils.JSONObject, error) {