mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-07-01 02:24:47 +08:00
fix(cloudmon): 飞天云监控中拉取metadata信息
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user