Prometheus - group_left

2021-09-27

aliyun_acs_rds_dashboard_ConnectionUsage 返回值

aliyun_acs_rds_dashboard_ConnectionUsage{endpoint="http",instance="aliyun-rds-exporter",instanceId="rm-bp14ckfo8e8g38dgr",job="aliyun-rds-exporter",namespace="monitoring",pod="aliyun-rds-exporter-5db55676c9-7cdlt",prometheus="monitoring/k8s",service="aliyun-rds-exporter",userId="1272341559673249"}

aliyun_meta_rds_info 返回值

aliyun_meta_rds_info{ConnectionMode="Standard",ConnectionString="rm-bp14ckfo8e8g38dgr.mysql.rds.aliyuncs.com",CreateTime="2019-05-09T03:00:36Z",DBInstanceClass="mysql.n2.medium.1",DBInstanceDescription="mysql-ops.pro.yqn.corp",DBInstanceId="rm-bp14ckfo8e8g38dgr",DBInstanceNetType="Intranet",DBInstanceStatus="Running",DBInstanceType="Primary",Engine="MySQL",EngineVersion="5.7",ExpireTime="2021-10-09T16:00:00Z",InsId="1",InstanceNetworkType="VPC",LockMode="Unlock",MutriORsignle="False",PayType="Prepaid",RegionId="cn-hangzhou",ResourceGroupId="rg-acfmxkbuusnidii",TipsLevel="0",VSwitchId="vsw-bp1adxj7ghbfsm6mkv36p",VpcCloudInstanceId="rm-bp14ckfo8e8g38dgr",VpcId="vpc-bp1v1o46xkaingzalvmvy",ZoneId="cn-hangzhou-f",endpoint="http",instance="aliyun-rds-exporter",job="aliyun-rds-exporter",namespace="monitoring",pod="aliyun-rds-exporter-5db55676c9-7cdlt",prometheus="monitoring/k8s",service="aliyun-rds-exporter"}

PromSql (group_left)

sum(aliyun_acs_rds_dashboard_ConnectionUsage
          * on (instanceId) group_left(DBInstanceDescription,ZoneId)
          label_replace(aliyun_meta_rds_info{DBInstanceDescription="mysql-ops.pro.yqn.corp"}, "instanceId", "$1", "DBInstanceId", "(.*)"))
        without (instance, userId, job)

group_left 返回值

{DBInstanceDescription="mysql-ops.pro.yqn.corp",ZoneId="cn-hangzhou-f",endpoint="http",instanceId="rm-bp14ckfo8e8g38dgr",namespace="monitoring",pod="aliyun-rds-exporter-5db55676c9-7cdlt",prometheus="monitoring/k8s",service="aliyun-rds-exporter"}