Commit e9754af8 authored by 胡凯旋's avatar 胡凯旋

add max

parent f9e61558
......@@ -18,8 +18,8 @@ class RDSCollector(object):
metrics = []
# 阿里云SDK查询字段与prometheus metric name的映射
queryname_metricname = {
'CpuUsage': 'rds_cpu_usage',
'DiskUsage': 'rds_disk_usage',
'CpuUsage': 'rds_cpu_usage_ratio',
'DiskUsage': 'rds_disk_usage_ratio',
}
metrics_from_aliyun = {}
all_rds_id = rds_instances.keys()
......@@ -39,13 +39,16 @@ class RDSCollector(object):
# transform to prometheus metric format
for queryname, datapoints in metrics_from_aliyun.items():
metricname = queryname_metricname[queryname]
metric_family = GaugeMetricFamily(metricname, metricname, labels=['rds_name'])
avg_metric_family = GaugeMetricFamily(metricname, metricname, labels=['rds_name'])
max_metricname = '{}_max'.format(metricname)
max_metric_family = GaugeMetricFamily(max_metricname, max_metricname, labels=['rds_name'])
for point in datapoints:
rds_name = rds_instances[point['instanceId']]
metric_family.add_metric([rds_name], point['Average'], point['timestamp']/1000)
avg_metric_family.add_metric([rds_name], point['Average']/100, point['timestamp']/1000)
max_metric_family.add_metric([rds_name], point['Maximum']/100, point['timestamp']/1000)
metrics.append(metric_family)
metrics.append(avg_metric_family)
for m in metrics:
yield m
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment