Adjust bundled Prometheus to scrape for only essential metrics #1805
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.
What does this PR change?
The
scrape_config
titledkubernetes-service-endpoints
currently attempts to scrape all service endpoints available in the cluster which include theprometheus.io/scrape: true
annotationBecause Kubecost only needs metrics from
kubecost-kube-state-metrics
,kubecost-prometheus-node-exporter
, andkubecost-network-costs
... Prometheus is scraping more than it needs to. This results in duplicate metrics, and errors when attempting to scrape a service endpoint which it doesn't have permissions to scrape.This PR adds a filter in the
kubernetes-service-endpoints
scrape_config
so that it is only scraping for the metrics required by Kubecost.Does this PR rely on any other PRs?
No
How does this PR impact users? (This is the kind of thing that goes in release notes!)
If users were querying any metrics from Kubecost’s bundled prometheus that are not listed here: https://github.com/kubecost/docs/blob/main/user-metrics.md, they will be affected.
Links to Issues or ZD tickets this PR addresses or fixes
How was this PR tested?
Using the following
values.yaml
, I verified on the Prometheus server that all metrics endpoints required by Kubecost were still being scraped, while all excess metrics endpoints (e.g.kube-dns
) were no longer scraped.kubectl port-forward svc/kubecost-prometheus-server 8080:80
Have you made an update to documentation?
No