mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #14278 from ioito/hotfix/qx-cloudmon-metric
fix(cloudmon): report influxdb data
This commit is contained in:
@@ -636,7 +636,7 @@ func cloudproviderRunfunc(ctx context.Context, factory ICloudReportFactory, prov
|
||||
session *mcclient.ClientSession) {
|
||||
opt := o.Options
|
||||
group, _ := errgroup.WithContext(ctx)
|
||||
for i, _ := range ResMonTypeList {
|
||||
for i := range ResMonTypeList {
|
||||
resType := ResMonTypeList[i]
|
||||
group.Go(func() error {
|
||||
log.Errorf("cloudprovider: %s,operator: %s start report().", provider.Name, resType)
|
||||
@@ -658,7 +658,8 @@ func CustomizeRunFunc(ctx context.Context, factory ICloudReportFactory, provider
|
||||
opt := o.Options
|
||||
err := factory.NewCloudReport(provider, session, &opt.ReportOptions, "").Report()
|
||||
if err != nil {
|
||||
log.Errorf("provider: %s report metric err: %v", provider.Name, err)
|
||||
// provider maybe nil
|
||||
log.Errorf("provider: %v report metric err: %v", provider, err)
|
||||
return
|
||||
}
|
||||
log.Errorf("operator: %s report() end.", factory.GetId())
|
||||
|
||||
@@ -164,6 +164,12 @@ func init() {
|
||||
newMetricFieldCreateInput("write_bytes", "Bytes write", monitor.METRIC_UNIT_BYTE, 6),
|
||||
})
|
||||
|
||||
// vm_disk
|
||||
RegistryMetricCreateInput("vm_disk", "Guest disk", monitor.METRIC_RES_TYPE_GUEST,
|
||||
monitor.METRIC_DATABASE_TELE, 3, []monitor.MetricFieldCreateInput{
|
||||
newMetricFieldCreateInput("used_percent", "Used vm disk rate", monitor.METRIC_UNIT_PERCENT, 1),
|
||||
})
|
||||
|
||||
// vm_mem
|
||||
RegistryMetricCreateInput("vm_mem", "Guest memory", monitor.METRIC_RES_TYPE_GUEST,
|
||||
monitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{
|
||||
|
||||
@@ -50,10 +50,12 @@ func (m *SMetricData) Line() string {
|
||||
|
||||
line := strings.Builder{}
|
||||
line.WriteString(m.Name)
|
||||
keys := map[string]bool{}
|
||||
for i := range m.Tags {
|
||||
if len(m.Tags[i].Key) > 0 && len(m.Tags[i].Value) > 0 {
|
||||
if _, ok := keys[m.Tags[i].Key]; !ok && len(m.Tags[i].Key) > 0 && len(m.Tags[i].Value) > 0 {
|
||||
line.WriteByte(',')
|
||||
line.WriteString(m.Tags[i].String())
|
||||
keys[m.Tags[i].Key] = true
|
||||
}
|
||||
}
|
||||
line.WriteByte(' ')
|
||||
|
||||
Reference in New Issue
Block a user