Grafana Cloud

Manage costs

Cost monitoring is a feature of Kubernetes Monitoring that enables you to manage the cost of cloud resources that your Kubernetes infrastructure is consuming. You can examine visualizations that unlock comprehensive insights about spending in these views:

  • Cost
  • Pod details
  • Container details

Kubernetes Monitoring uses an OpenCost integration and Grafana’s experience in managing Kubernetes-related costs. OpenCost uses information about your Cluster to provide metrics that measure infrastructure and container costs in real time. These insights enable you to make data-driven decisions about resource allocation, scaling strategies, and technology investments. With cost monitoring, you can immediately begin to:

  • Observe costs per resource and infrastructure type.
  • Identify savings based on unused CPU, RAM, and storage that stays untouched for a specific period of time.
  • Gain insight on the costs of network egress and GPU.
  • Compare savings and costs trends.
  • Use the time range selector to show historical costs.
    **Cost** view with costs over last 6-month period
    Cost view with costs over last 6-month period

Use cost monitoring strategically

Here are some strategies you can use to manage the costs of your Kubernetes infrastructure:

  • Examine costs over a time period on the Pod and container detail pages:
  • Compare costs. At the Cost view, use the Cluster filter to compare costs across different cloud providers or Kubernetes distributions to gain insight per cloud provider and per Cluster.
  • Verify scaling. Assess the cost implications of scaling resources by using Kubernetes autoscaling mechanisms. With horizontal and vertical autoscalers, you can dynamically adjust resource allocation based on demand. Then verify your adjustments are reducing costs by using Kubernetes Monitoring to compare the past and present resource allocation.
  • Right-size your Clusters, namespaces and Nodes. Use the Efficiency view and dashboard to:
    • Reduce number of Nodes where resources are scarcely utilized.
    • Work on better Pods and namespace placement to optimize the usage of the resources already available.
    • Discover and optimize resource intensive workloads and Pods.
    • Manage the availability of resources among your Clusters.
  • Refine and monitor practices and policies. Establish cost governance practices and policies based on the curated data uncovered by Kubernetes cost monitoring.

Refine cost estimates

Cost monitoring estimates infrastructure costs based on the Cluster provider ID and built-in pricing guides. However, the default provider ID doesn’t include cost adjustments that you receive from the vendor, such as discounts. To further refine the estimate to include any negotiated pricing that is specific to your account, visit these vendor links for instructions:

  • AWS
  • Azure
  • GCP
    • Enable the Cloud Billing API.
    • Create an API key, and optionally edit the key and restrict to the Cloud Billing API.
    • Edit the OpenCost Deployment on the Kubernetes Cluster, and set the CLOUD_PROVIDER_API_KEY to the newly created API key.

If you use a Cluster provider other than the top three vendors, refer to Managing with the OpenCost Helm chart to configure custom pricing.

Configure or upgrade

Cost monitoring is a choice you can switch on or off when you configure with Grafana Kubernetes Monitoring Helm chart.

If you have already deployed Kubernetes Monitoring using Agent or Agent Operator, follow the instructions to upgrade Kubernetes Monitoring.

Cardinality with OpenCost

To understand the impact of using OpenCost on cardinality, refer to Available Prometheus Metrics for OpenCost.