diff --git a/pkg/cloudmon/collectors/alimon/aliservice.go b/pkg/cloudmon/collectors/alimon/aliservice.go index 635af5c5c3..02b3f4a877 100644 --- a/pkg/cloudmon/collectors/alimon/aliservice.go +++ b/pkg/cloudmon/collectors/alimon/aliservice.go @@ -164,11 +164,6 @@ func (self *SAliCloudReport) collectMetricFromThisServer(server jsonutils.JSONOb Key: pairsKey, Value: strconv.FormatFloat(fieldValue, 'E', -1, 64), }) - if common.MonType(self.Operator) == common.SERVER { - self.AddMetricTag(&metric, common.OtherVmTags) - } else { - self.AddMetricTag(&metric, common.OtherTags) - } metric.Name = measurement return metric, nil } diff --git a/pkg/cloudmon/collectors/apsaramon/apsaraservice.go b/pkg/cloudmon/collectors/apsaramon/apsaraservice.go index 5bd5423403..3a4623d0f7 100644 --- a/pkg/cloudmon/collectors/apsaramon/apsaraservice.go +++ b/pkg/cloudmon/collectors/apsaramon/apsaraservice.go @@ -27,6 +27,7 @@ import ( api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudmon/collectors/common" "yunion.io/x/onecloud/pkg/cloudprovider" + iden_modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity" "yunion.io/x/onecloud/pkg/multicloud/apsara" "yunion.io/x/onecloud/pkg/util/influxdb" ) @@ -92,6 +93,24 @@ func (self *SApsaraCloudReport) collectRegionMetricOfHost(region cloudprovider.I log.Errorf("collect %s error: %v", metricName, err) continue } + + project, err := self.GetResourceById(server.ProjectId, &iden_modules.Projects) + if err != nil { + log.Errorf("server: %s getProject: %s err: %v", server.Name, server.ProjectId, err) + continue + } + metaMap, _ := project.GetMap("metadata") + if len(metaMap) > 0 { + for key, valObj := range metaMap { + if strings.Contains(key, "user:") { + val, _ := valObj.GetString() + serverMetric.Tags = append(serverMetric.Tags, influxdb.SKeyValue{ + Key: key, + Value: val, + }) + } + } + } dataList = append(dataList, serverMetric) } } @@ -301,7 +320,6 @@ func (self *SApsaraCloudReport) collectMetricFromThisServer(server jsonutils.JSO Key: pairsKey, Value: strconv.FormatFloat(fieldValue, 'E', -1, 64), }) - self.AddMetricTag(&metric, common.OtherVmTags) metric.Name = measurement return metric, nil } diff --git a/pkg/cloudmon/collectors/azuremon/azureservice.go b/pkg/cloudmon/collectors/azuremon/azureservice.go index 8809a78e70..9da35a2206 100644 --- a/pkg/cloudmon/collectors/azuremon/azureservice.go +++ b/pkg/cloudmon/collectors/azuremon/azureservice.go @@ -150,7 +150,6 @@ func (self *SAzureCloudReport) collectMetricFromThisServer(server jsonutils.JSON Key: pairsKey, Value: strconv.FormatFloat(fieldValue, 'E', -1, 64), }) - self.AddMetricTag(&metric, common.OtherVmTags) datas = append(datas, metric) } } diff --git a/pkg/cloudmon/collectors/common/basemon.go b/pkg/cloudmon/collectors/common/basemon.go index 5a2896733f..e9c8c2cce0 100644 --- a/pkg/cloudmon/collectors/common/basemon.go +++ b/pkg/cloudmon/collectors/common/basemon.go @@ -165,7 +165,12 @@ func (self *CloudReportBase) InitProviderInstance() (cloudprovider.ICloudProvide Secret: secretDe, Vendor: self.SProvider.Provider, ProxyFunc: proxyFunc, - Options: options.(*jsonutils.JSONDict), + } + if options != nil { + cfg.Options = options.(*jsonutils.JSONDict) + defaultRegion, _ := options.GetString("default_region") + cfg.DefaultRegion = defaultRegion + } return cloudprovider.GetProvider(cfg) } diff --git a/pkg/cloudmon/collectors/common/multiCloudMonUtils.go b/pkg/cloudmon/collectors/common/multiCloudMonUtils.go index e1ab4959fd..a2d8ee6a8e 100644 --- a/pkg/cloudmon/collectors/common/multiCloudMonUtils.go +++ b/pkg/cloudmon/collectors/common/multiCloudMonUtils.go @@ -422,6 +422,22 @@ func JsonToMetric(obj *jsonutils.JSONDict, name string, tags map[string]string, Key: k, Value: val, }) } + //if k == "metadata" { + // mValMap, err := v.GetMap() + // if err != nil { + // log.Errorf("get metadata value err: %v", err) + // continue + // } + // for mKey, mValObj := range mValMap { + // if strings.Contains(mKey, "sys") { + // mVal, _ := mValObj.GetString() + // tagPairs = append(tagPairs, influxdb.SKeyValue{ + // Key: mKey, + // Value: mVal, + // }) + // } + // } + //} } metric.Tags = tagPairs metric.Metrics = metricPairs diff --git a/pkg/cloudmon/collectors/huaweimon/hwservice.go b/pkg/cloudmon/collectors/huaweimon/hwservice.go index 8b3b38921d..6bcfa0c88f 100644 --- a/pkg/cloudmon/collectors/huaweimon/hwservice.go +++ b/pkg/cloudmon/collectors/huaweimon/hwservice.go @@ -336,7 +336,6 @@ func (self *SHwCloudReport) collectMetricFromThisServer(server jsonutils.JSONObj Value: strconv.FormatFloat(fieldValue, 'E', -1, 64), }) metric.Name = measurement - self.AddMetricTag(&metric, common.OtherVmTags) return metric, nil } diff --git a/pkg/cloudmon/collectors/jdmon/jdservice.go b/pkg/cloudmon/collectors/jdmon/jdservice.go index 6ee16b8250..dec16fa94d 100644 --- a/pkg/cloudmon/collectors/jdmon/jdservice.go +++ b/pkg/cloudmon/collectors/jdmon/jdservice.go @@ -132,7 +132,6 @@ func (self *SJdCloudReport) collectMetricFromThisServer(server jsonutils.JSONObj Value: strconv.FormatFloat(fieldValue, 'E', -1, 64), }) metric.Name = measurement - self.AddMetricTag(&metric, common.OtherVmTags) datas = append(datas, metric) } } diff --git a/pkg/cloudmon/collectors/qcmon/qcloudservice.go b/pkg/cloudmon/collectors/qcmon/qcloudservice.go index 664622d8f0..50660d1057 100644 --- a/pkg/cloudmon/collectors/qcmon/qcloudservice.go +++ b/pkg/cloudmon/collectors/qcmon/qcloudservice.go @@ -186,7 +186,6 @@ func (self *SQCloudReport) collectMetricFromThisServer(server jsonutils.JSONObje Key: pairsKey, Value: strconv.FormatFloat(fieldValue, 'E', -1, 64), }) - self.AddMetricTag(&metric, common.OtherVmTags) datas = append(datas, metric) } return datas, nil diff --git a/pkg/cloudmon/collectors/vmwaremon/vmwareservice.go b/pkg/cloudmon/collectors/vmwaremon/vmwareservice.go index a275b46961..8557468fe7 100644 --- a/pkg/cloudmon/collectors/vmwaremon/vmwareservice.go +++ b/pkg/cloudmon/collectors/vmwaremon/vmwareservice.go @@ -227,7 +227,6 @@ func (self *SEsxiCloudReport) collectMetricFromThisServer_(server jsonutils.JSON if monType == common.TYPE_HOSTSYSTEM { self.AddMetricTag(&metric, common.OtherHostTag) } else { - self.AddMetricTag(&metric, common.OtherVmTags) } datas = append(datas, metric) }