grafana / cloudcost-exporter

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

compute: allow "instance" label name to be set (behind a flag) #266

Closed jjo closed 4 weeks ago

jjo commented 2 months ago

Fixes #262.

What

Allow instance label name to be set via new -compute.instance-label flag.

Why

See #262 for the rationale and discussion.

How

Testing

Adapted testing with a couple ComputeInstanceLabel="node" changes, although it should be improved to test changes to the label name.

-- Signed-off-by: JuanJo Ciarlante juanjosec@gmail.com

jjo commented 2 months ago

BTW also manually tested it locally with:


$ ./cloudcost-exporter  --aws.profile $DEV_PROFILE --aws.region us-east-1 --aws.services ec2 --compute.instance-label node
[...]

$ curl -s http://localhost:8080/metrics | egrep ^cloudcost_aws
[...]
cloudcost_aws_ec2_instance_total_usd_per_hour{cluster_name="<EDITED>",family="General purpose",machine_type="m6g.xlarge",node="ip-10-60-5-156.us-east-2.compute.internal",price_tier="ondemand",region="us-east-2"} 0.154
cloudcost_aws_ec2_instance_total_usd_per_hour{cluster_name="<EDITED>",family="General purpose",machine_type="m7g.2xlarge",node="ip-10-60-11-138.us-east-2.compute.internal",price_tier="spot",region="us-east-2a"} 0.1292
cloudcost_aws_ec2_instance_total_usd_per_hour{cluster_name="<EDITED>",family="General purpose",machine_type="m7g.2xlarge",node="ip-10-60-3-71.us-east-2.compute.internal",price_tier="spot",region="us-east-2a"} 0.1292
[...]
jjo commented 4 weeks ago

Closing as this was intended as a PoC / exploration to sense the feasibility and complexity on adding such flag, then we also agreed on not moving fwd with this approach.