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

add project tag

parent 182c55bc
......@@ -61,6 +61,8 @@ tencent_instances:
memory_usage_factor: 1
# 数据库类型,主库(master)or从库(slave), 默认master
type: master
# 所属项目,默认gengmei, 选项 [gengmei/alpha]
project: gengmei
instance_id2:
name: instance_name2
......
......@@ -57,11 +57,11 @@ class TencentExporter(Exporter):
metricname = metric['name']
factor = metric.get('factor', None)
avg_metric_family = GaugeMetricFamily(metricname, metricname, labels=[
'rds_name', 'type', 'service_provider'
'rds_name', 'type', 'service_provider', 'project'
])
with_factor_metricname = '{}_with_factor'.format(metricname)
with_factor_metric_family = GaugeMetricFamily(with_factor_metricname, with_factor_metricname, labels=[
'rds_name', 'type', 'service_provider'
'rds_name', 'type', 'service_provider', 'project'
])
for instance_data in instance_data_list:
......@@ -70,12 +70,13 @@ class TencentExporter(Exporter):
instance = self.instances[instance_id]
instance_name = instance['name']
instance_type = instance.get('type', 'master')
instance_project = instance.get('project', 'gengmei')
# 当前queryname,当前rds实例的因子,若没有配置,默认为1
rds_factor = instance.get(factor, 1)
for value in timestamp_value_dict.values():
avg_metric_family.add_metric([instance_name, instance_type, service_provider], value)
avg_metric_family.add_metric([instance_name, instance_type, service_provider, instance_project], value)
with_factor_metric_family.add_metric(
['{}*{}'.format(instance_name,rds_factor), instance_type, service_provider],
['{}*{}'.format(instance_name,rds_factor), instance_type, service_provider, instance_project],
value*rds_factor)
metrics_to_export.extend([avg_metric_family, with_factor_metric_family])
......
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