The cloud bill rose 20% after a release, and nobody knows which team caused it. That is the situation where OpenCost Kubernetes earns a look: an open source project, licensed Apache 2.0 according to the LICENSE file in the opencost/opencost repository, that splits a cluster’s spend across namespaces, controllers and pods.
This article starts from an operations question, « which change moved the cost, and where can I see it? », rather than from a feature tour. The facts come from the repository README and the documentation on opencost.io, read on 11 November 2026. span.observer did not deploy OpenCost for this piece: the snippets below reproduce commands and formulas from the documentation, with sample values.
The topic is separate from our article on effective CPU requests, which tunes a pod’s resources. Here we turn those resources into money.
OpenCost Kubernetes: what the project does and does not do
- Licence and status: Apache 2.0; opencost.io describes it as a Cloud Native Computing Foundation incubating project.
- Origin: built and open sourced by Kubecost, per the README. The repository combines a specification and a Go implementation; the web UI lives in a separate repository,
opencost/opencost-ui. - Scope: cost allocation by cluster, node, namespace, controller kind, controller, service or pod, for CPU, GPU, memory and persistent volumes. Cloud costs for AWS, Azure and GCP are covered too, and custom CSV pricing handles on-premises clusters.
- Extras listed in the README: a Prometheus export on
/metrics, carbon costs, an MCP server and cost tracking for vLLM-based inference. I tested none of these.
One limit to keep in mind: OpenCost estimates and allocates spend. It replaces neither the provider invoice nor a performance analysis.
How OpenCost computes a cost
To judge whether a number is credible, you need the recipe. The specification splits total cluster cost into two families: assets (nodes, volumes, disks, load balancers, network traffic) and overhead, such as cluster management fees.
An asset costs either an allocation (you pay for reserved time, whatever the usage) or a usage (you pay per unit, such as bytes egressed). The documentation gives the formulas.
The second line matters most for decisions. Workload costs plus idle costs plus overhead equal total cost. Idle cost is the share of allocated resources that no workload claims. An oversized cluster is therefore never « free »: its spend reappears in that line.
Installing without misreading the prerequisites
The README says installation goes through the official Helm chart only, on Kubernetes 1.20 or later; the standalone manifests were removed:
helm repo add opencost https://opencost.github.io/opencost-helm-chart helm repo update helm install opencost opencost/opencost Mind a nuance in the documentation. The installation page calls Prometheus a prerequisite for scraping and storage, with a PROMETHEUS_SERVER_ENDPOINT variable to point at your server. The integration page states that a Prometheus client is not needed to emit the cost metrics. The two statements can be reconciled: OpenCost reads its input data from Prometheus and can then expose its own metrics. I did not verify this on a cluster.
The expected inputs come from node-exporter (for example node_cpu_seconds_total) and kube-state-metrics (for example kube_pod_container_resource_requests). If your Prometheus already scrapes kube-state-metrics, the documentation warns of possible duplicate metrics. A sharded Prometheus needs a global query endpoint such as Thanos Query or Mimir; see our article on Mimir for that storage layer.
Querying the cost API
The API listens on port 9003 of the service by default. The documentation shows how to reach it locally, then three typical queries:
Three parameters shape how you read the result:
-
windowsets the period:7d,today, an RFC3339 date pair or Unix timestamps. -
aggregatepicks the grouping key: namespace, controller, pod, but also a label (label:app) or an annotation. -
shareIdle=truespreads idle cost in proportion to each allocation’s non-idle cost.idleByNode=truecomputes it per node instead of for the whole cluster.
The resolution parameter trades accuracy against memory: 1 minute by default, finer for short-lived pods, cheaper in queries with a larger value. For a ten-minute job, avoid a coarse resolution.
Connecting cost to observability
This is where the topic leaves finance. OpenCost exposes its results as Prometheus metrics. A single scrape configuration puts them next to your latencies and error rates.
The documentation also offers starter queries, for example sum(node_total_hourly_cost) * 730 for the monthly cost of all nodes, or sum(kubecost_load_balancer_cost) by (namespace) for load balancers per namespace. The kubecost_ prefix on some metrics is a legacy of the original project.
Three practical uses come out of this join:
- Annotate a release: overlay a namespace’s hourly cost on the deployment timeline. If the line climbs with version 42, you have your suspect.
- Compare cost with traffic: a service whose cost rises while its requests per second stay flat deserves a review of its requests and limits.
- Alert on drift: a rule on one namespace, modelled on our Prometheus recording rules, beats a surprise at month end.
Watch cardinality: every label you add to metrics multiplies the series. Reread the article on Kubernetes metric cardinality before filtering on ephemeral pod labels.
For Prometheus versus OpenTelemetry, see our comparison. What I read about OpenCost goes through Prometheus; I did not verify a native OpenTelemetry export.
The MCP server: enable it knowingly
The README describes an MCP server, disabled by default and enabled with --set opencost.mcp.enabled=true, listening on port 8081. It exposes get_allocation_costs, get_asset_costs, get_cloud_costs and get_efficiency (rightsizing recommendations), among others. An agent could then answer « which namespace grew most this week? ». As with any agent, scope its access before opening it: see our analysis of SRE agent promises.
Limits and unverified points
- List prices: the allocation API is based on on-demand pricing; discounts and commitments show up through cloud costs, if you connect them.
- Star count, current version, real-world traffic: not collected, so not quoted.
- Prometheus prerequisite: the documentation wording is ambiguous; validate it on your version.
- Dynatrace: no official link between OpenCost and Dynatrace was read for this article. Do not assume an integration.
Best practices
- Standardise
teamandapplabels before installing: without them, label aggregation stays empty. - Start on a single cluster and compare the total with last month’s invoice.
- Keep the MCP server disabled until a written need exists.
- Track idle cost as a capacity indicator, not as a team’s fault.
Frequently asked questions
Is OpenCost free?
The code is Apache 2.0 and the documentation is CC BY 4.0. The cost of the cluster that hosts it, and of Prometheus, stays with you.
Does OpenCost replace the cloud provider invoice?
No. It allocates and estimates spend from prices and metrics. Always reconcile its total with the invoice.
Do I need Prometheus to use OpenCost?
The installation documentation describes it as a prerequisite, with a configurable endpoint. The integration page states that a Prometheus client is not needed to emit the cost metrics.
Conclusion
OpenCost is worth a trial if « who costs what » comes up at every invoice review. Start with one cluster, a seven-day window and namespace aggregation, then overlay the result on your releases. Sources: the OpenCost documentation and the opencost/opencost repository.
span.observer is an independent community blog, not affiliated with Dynatrace LLC or the OpenCost project. Trademarks belong to their owners. Tools change quickly: check commands and options against the official documentation.
Originally published on span.observer. French version: https://span.observer/fr/opencost-kubernetes-couts-observabilite/.






