grafana / cloudcost-exporter

Prometheus Exporter for Cloud Provider agnostic cost metrics
Apache License 2.0
30 stars 1 forks source link

feat(ec2): Add name label to exported metrics #286

Closed Pokom closed 1 month ago

Pokom commented 1 month ago

Adds instance_id label to the three cloudcost_aws_ec2_instance... cost metrics. The intent is to be able to join the cost metrics with aws_ec2_info to be able to extract labels such as team and environments. An example query would be:

sum by (tag_team) (
    cloudcost_aws_ec2_instance_total_usd_per_hour
    + on(instance_id) group_right(tag_team)
    (
        label_replace(aws_ec2_info{}, "instance_id", "$1", "name", ".+/(.+)")
    )
)