grafana / cloudcost-exporter

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

AWS: Regression in exporting S3 metrics #64

Closed Pokom closed 9 months ago

Pokom commented 9 months ago

After merging in #63, I noticed a regression that the test suite didn't capture. The first scrape would be successful and output metrics. The second one I ended up with this cryptic log statement:

curl http://localhost:8080/metrics
An error has occurred while serving metrics:

error collecting metrics for "S3"

It's not hard to trace the issue. It originates in s3.go#Collect: https://github.com/grafana/cloudcost-exporter/blob/main/pkg/aws/s3/s3.go#L142-L145

We put in protective measures here to ensure we don't overload requests to aws's costexplorer since it costs $0.01/api call. This returns 0.0 which we consider an error in CollectMetrics: https://github.com/grafana/cloudcost-exporter/blob/main/pkg/aws/aws.go#L72-L74

A few ways we can handle this: