grafana / cloudcost-exporter

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

fix(pvc): Get disk name from k8s labels instead #142

Closed Pokom closed 6 months ago

Pokom commented 6 months ago

When comparing the output data from opencost and cloudcost exporter, one bit that didn't quite make sense was a mismatch in PVC's between the two. The total costs between the two was small enough to be insignificant, which only made things more confusing.

After analyzing the metrics further, the biggest difference was the name of the disks. cloudcost-exporter was pulling the name directly from the disk metadata, which was prepending most pv's with gke-$cluster. The problem with this is that kube-state-metrics and other metrics only look at what k8s calls them.

This change updates how name is sourced.

  1. Loads the disk.Description into a map
  2. Check for the existence of two labels
  3. If either keys are found, return the value
  4. Otherwise, fall back to disk.Name as a final resource