Opencost Allocation Api
An OpenCostAllocationAPI property references an API endpoint that exposes Kubernetes and cloud infrastructure cost allocation data in a format compatible with the OpenCost Allocation API specification. The OpenCost API returns workload cost data aggregated by namespace, deployment, pod, service, or label, and supports time-window queries and shared cost distribution. Indexing an OpenCost-compatible allocation endpoint makes container cost data programmatically accessible to FinOps dashboards, chargeback tools, and engineering teams.
Also known as: OpenCost API, Kubernetes Cost Allocation API, Allocation Endpoint
Example
Standards
- CNCF / OpenCost OpenCost Specification
- CNCF (Incubating) OpenCost project
- CNCF / OpenCost OpenCost API documentation
- CNCF / Prometheus Prometheus exposition format
- CNCF OpenMetrics
- CNCF / Kubernetes Kubernetes API
Media Types
application/json— Primary response media type for OpenCost allocation queries.text/plain— Used for Prometheus metrics scraping (text exposition format).
OpenAPI Expression
-
paths./allocation(OpenCost API) — Allocation endpoint accepts window, aggregate, and accumulate query parameters. -
paths./allocation/compute(OpenCost API) — On-demand allocation computation endpoint. -
paths./assets(OpenCost API) — Returns cluster-level asset cost data.
Governance Rules
window-required(OpenCost API) — Allocation queries must specify a time window (e.g., '7d', '2024-01-01,2024-01-31').aggregate-known-keys(OpenCost API) — aggregate parameter must use supported keys (namespace, deployment, pod, controller, service, label:, etc.). idle-handling-declared(OpenCost Specification) — Responses should declare whether idle costs are included, shared, or excluded.shared-cost-explicit(OpenCost Specification) — Any shared-cost distribution policy applied to the response must be discoverable.
Risk & Compliance
Compliance:
- SOC 2 — cost allocation data informs chargeback and internal financial controls
- GDPR — allocation labels may carry tenant or user identifiers
Security: Allocation APIs disclose workload-level spend, label values, and capacity posture; require authentication and consider scoping by namespace or RBAC role.
Tools
- OpenCost — Cost allocation engine (Apache-2.0)
- Kubecost — Commercial OpenCost distribution
- Prometheus — Metrics backend (Apache-2.0)
- Grafana — Dashboards for OpenCost (AGPL-3.0)
- Thanos — Long-term metrics storage (Apache-2.0)
- kubectl cost — CLI client (Apache-2.0)
Suggested Metrics
allocation_query_latency_p95_ms— 95th-percentile latency of /allocation requests.allocation_rows_returned— Number of aggregated allocation rows in a response.idle_cost_share— Fraction of total cost attributed to idle resources in the window.shared_cost_share— Fraction of total cost distributed via shared-cost rules.cluster_cost_total— Total cluster cost over the queried window.
Example Implementations
- OpenCost — Reference implementation of the OpenCost Allocation API.
- Kubecost — Commercial distribution that implements the OpenCost API.
Related Properties
- Opencost specification
- Focus billing export
- Focus conformance report
- Finops framework
- Pricing
Tags
- OpenCost
- FinOps
- Kubernetes
- Cost Allocation
- API