Grafana Cloud

Manage costs

You can manage the cost of your Kubernetes infrastructure by discovering insights starting at the Cluster level. You can use cost and savings information to make data-driven decisions about resource allocation, scaling strategies, and technology investments. Cost monitoring is an optional feature when you configure with Grafana Kubernetes Monitoring Helm chart.

Out of the box, you can:

  • Observe cost per resource and infrastructure type.
  • View historical and projected costs.
  • Identify potential savings opportunities.
  • Learn the costs of network egress and GPU.
  • Compare savings and costs trends.

As part of managing costs, you can use two approaches:

How it works

Kubernetes Monitoring uses an OpenCost integration along with the experience of Grafana in managing Kubernetes-related costs to calculate cost data. OpenCost uses information about your Kubernetes components to provide metrics that measure infrastructure costs in real time.

Keep in mind that cost calculations depend on the type of object within Kubernetes. For example, some objects have a known cost, while the cost of others are derived from a calculation.

Refine cost estimates

Costs shown in Kubernetes Monitoring are estimates of your infrastructure costs based on the node type, size, region, and public pricing lists. However, the default pricing 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, you can configure custom pricing using the OpenCost Helm chart.

Known cost of Nodes and Clusters

Cloud provider costs are gathered per Node, so each Node (and therefore each Cluster) has a known cost. OpenCost estimates what proportion of the total Node cost can be associated with CPU and memory.

Allocated cost

For the cost of any resource not at the Node or Cluster level (containers, Pods, namespaces, and workloads), Kubernetes Monitoring uses an allocation algorithm in combination with OpenCost hourly cost estimates for CPU and memory proportional costs.

Allocation is derived by taking the greater amount of either the actual usage or the requested amount. The sum of the CPU and memory allocation in each hour is multiplied by the hourly CPU and memory cost, which is estimated by OpenCost.

Idle costs

For Nodes and Clusters, idle cost is calculated by the difference between usage and physical capacity. For resources not at the Node or Cluster level, idle cost is calculated by the difference between usage and requests. Requests act as reserved resources, so unused requests can’t be used by other objects in Kubernetes.

Cardinality with OpenCost

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