Migrate to using cloudcost-exporter metrics#30
Merged
Conversation
First attempt at trying to migrate to using cloudcost-exporter metrics. Took a naive approach of adding a config to toggle cloudcost-exporter metrics. Added three new queries for cloudcost-exporter to get the avg cost of - Cpu cores - Memory (GiB) - Persistent Volumes Discovered that cloudcost-exporter does not implement cost of persistent storage(see grafana/cloudcost-exporter#236). To test out, follow the setup guide and run the estimator command: ```shell go run ./cmd/estimator/ \ -from $PWD/pkg/costmodel/testdata/resource/Deployment.json \ -to $PWD/pkg/costmodel/testdata/resource/Deployment-more-requests.json \ -http.config.file ~/.config/dev.yaml \ -prometheus.address $PROMETHEUS_ADDRESS \ dev-us-east-0 ``` - relates #29
Pokom
commented
Feb 5, 2025
Comment on lines
+239
to
+249
| // Handles the case for cloudcost exporter metrics where `price_tier` is the label for spot/non-spot | ||
| // TODO: Delete after removing support for OpenCost | ||
| switch sample.Metric["price_tier"] { | ||
| case "ondemand": | ||
| cost.NonSpot = value | ||
| case "spot": | ||
| cost.Spot = value | ||
| default: | ||
| // This is when there is no spot/non-spot label | ||
| cost.Dollars = value | ||
| } |
Contributor
Author
There was a problem hiding this comment.
This is really the heart of the change. The biggest difference between the queries is that the price_tier label is used to signify if the price is for an ondemand or spot instance.
spinillos
reviewed
Feb 11, 2025
nikimanoledaki
approved these changes
Feb 12, 2025
Contributor
There was a problem hiding this comment.
Reviewed (LGTM!) & validated for both GKE & EKS after setting USE_CLOUD_COST_EXPORTER=true:
go run ./cmd/estimator/ \
-from $PWD/pkg/costmodel/testdata/resource/Deployment.json \
-to $PWD/pkg/costmodel/testdata/resource/Deployment-more-requests.json \
-http.config.file ~/.config/grafana/dev2.yaml \
-prometheus.address=$PROMETHEUS_ADDRESS \
dev-us-east-0
loading http config file: /Users/nikimanoledaki/.config/grafana/dev2.yaml
Cluster Total Weekly Cost Δ Weekly Cost Total Monthly Cost Δ Monthly Cost
<cost data>
🤞
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First attempt at trying to migrate to using cloudcost-exporter metrics. Took a naive approach of adding a config to toggle cloudcost-exporter metrics. Added two new queries for cloudcost-exporter to get the avg cost of
Discovered that cloudcost-exporter does not implement cost of persistent storage(see grafana/cloudcost-exporter#236), so I'll pick that up in a separate PR.
To test out, follow the setup guide and run the estimator command:
Since this releases the change behind a flag, we can merge this whenever we're comfortable and enable it when we're comfortable.