| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634 |
- {
- "openapi": "3.0.1",
- "info": {
- "title": "OpenCost API",
- "description": "The OpenCost API provides real-time and historical reporting of Kubernetes cloud costs.",
- "license": {
- "name": "Apache 2.0",
- "url": "https://www.apache.org/licenses/LICENSE-2.0.html"
- },
- "version": "0.1"
- },
- "servers": [
- {
- "url": "http://localhost:9003",
- "description": "kubectl port-forward --namespace opencost service/opencost 9003"
- }
- ],
- "paths": {
- "/allocation/compute": {
- "get": {
- "summary": "query for costs and resources allocated to Kubernetes workloads",
- "description": "The standard OpenCost API query for costs and resources allocated to Kubernetes workloads. You may specify the `window` date range, the Kubernetes primitive to `aggregate` on, the `step` for the duration of returned sets, and the `resolution` for the duration to use for Prometheus queries.",
- "parameters": [
- {
- "name": "window",
- "in": "query",
- "description": "Duration of time over which to query. Accepts: words like `today`, `week`, `month`, `yesterday`, `lastweek`, `lastmonth`; durations like `30m`, `12h`, `7d`; [RFC3339](https://www.rfc-editor.org/rfc/rfc3339) date pairs like `2021-01-02T15:04:05Z,2021-02-02T15:04:05Z`; Unix timestamps like `1578002645,1580681045`.",
- "required": true,
- "style": "form",
- "explode": true,
- "schema": {
- "type": "string"
- },
- "examples": {
- "today": {
- "summary": "The current day",
- "value": "today"
- },
- "month": {
- "summary": "The month-to-date",
- "value": "month"
- },
- "lastweek": {
- "summary": "The previous week",
- "value": "lastweek"
- },
- "30m": {
- "summary": "The last 30 minutes",
- "value": "30m"
- },
- "12h": {
- "summary": "The last 12 hours",
- "value": "12h"
- },
- "7d": {
- "summary": "The previous 7 days",
- "value": "7d"
- },
- "range": {
- "summary": "A custom RFC3339 date range",
- "value": "2023-01-18T10:30:00Z,2023-01-19T10:30:00Z"
- },
- "unix": {
- "summary": "A custom Unix timestamp range",
- "value": "1674073869,1674193869"
- }
- }
- },
- {
- "name": "aggregate",
- "in": "query",
- "description": "Field by which to aggregate the results. Accepts: `all`, `cluster`, `node`, `namespace`, `controllerKind`, `controller`, `service`, `pod`, `container`, `label:<name>`, and `annotation:<name>`. Also accepts comma-separated lists for multi-aggregation, like `namespace,label:app`. Defaults to `cluster,node,namespace,pod,container`.",
- "required": false,
- "style": "form",
- "explode": true,
- "schema": {
- "type": "string"
- },
- "examples": {
- "cluster": {
- "summary": "Aggregates by the cluster.",
- "value": "cluster"
- },
- "node": {
- "summary": "Aggregates by the compute nodes in the cluster.",
- "value": "node"
- },
- "namespace": {
- "summary": "Aggregates by the namespaces in the cluster.",
- "value": "namespace"
- },
- "controllerKind": {
- "summary": "Aggregates by the kinds of controllers present in the cluster.",
- "value": "controllerKind"
- },
- "controller": {
- "summary": "Aggregates by the individual controllers within the cluster.",
- "value": "controller"
- },
- "service": {
- "summary": "Aggregates by the services within the cluster.",
- "value": "service"
- },
- "pod": {
- "summary": "Aggregates by the individual pods within the cluster",
- "value": "pod"
- },
- "container": {
- "summary": "Aggregates by the containers present in the cluster",
- "value": "container"
- },
- "all": {
- "summary": "Aggregates into a single allocation",
- "value": "all"
- }
- }
- },
- {
- "name": "step",
- "in": "query",
- "description": "Duration of a single allocation set. If unspecified, this defaults to the window, so that you receive exactly one set for the entire window. If specified, it works chronologically backward, querying in durations of step until the full window is covered. Default is `window`",
- "required": false,
- "style": "form",
- "explode": true,
- "schema": {
- "type": "string"
- },
- "examples": {
- "30m": {
- "summary": "30 minute steps over the duration of the window.",
- "value": "30m"
- },
- "2h": {
- "summary": "2 hour steps over the duration of the window",
- "value": "2h"
- },
- "1d": {
- "summary": "Daily steps over the duration of the window (ie. `lastweek` or `month`",
- "value": "1d"
- }
- }
- },
- {
- "name": "resolution",
- "in": "query",
- "description": "Duration to use as resolution in Prometheus queries. Smaller values (i.e. higher resolutions) will provide better accuracy, but worse performance (i.e. slower query time, higher memory use). Larger values (i.e. lower resolutions) will perform better, but at the expense of lower accuracy for short-running workloads. Default is `1m`",
- "required": false,
- "style": "form",
- "explode": true,
- "schema": {
- "type": "string"
- },
- "examples": {
- "1m": {
- "summary": "Highly accurate, slower query.",
- "value": "1m"
- },
- "30m": {
- "summary": "Less accurate, faster query. Not recommended for short-lived workloads.",
- "value": "30m"
- }
- }
- }
- ],
- "responses": {
- "200": {
- "description": "Success with `window` of `2d` and `aggregate` by `namespace`",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/inline_response_200"
- },
- "examples": {
- "0": {
- "value": "{\"code\":200,\"status\":\"success\",\"data\":[{\"kube-system\":{\"name\":\"kube-system\",\"properties\":{\"cluster\":\"cluster-one\",\"namespace\":\"kube-system\"},\"window\":{\"start\":\"2023-01-18T11:38:45Z\",\"end\":\"2023-01-20T11:38:45Z\"},\"start\":\"2023-01-18T11:38:45Z\",\"end\":\"2023-01-20T11:38:00Z\",\"minutes\":2879.235705,\"cpuCores\":0.449881,\"cpuCoreRequestAverage\":0.449881,\"cpuCoreUsageAverage\":0.009417,\"cpuCoreHours\":21.588536,\"cpuCost\":0.408822,\"cpuCostAdjustment\":0.000000,\"cpuEfficiency\":0.020932,\"gpuCount\":0.000000,\"gpuHours\":0.000000,\"gpuCost\":0.000000,\"gpuCostAdjustment\":0.000000,\"networkTransferBytes\":0.000000,\"networkReceiveBytes\":0.000000,\"networkCost\":0.000000,\"networkCostAdjustment\":0.000000,\"loadBalancerCost\":0.000000,\"loadBalancerCostAdjustment\":0.000000,\"pvBytes\":0.000000,\"pvByteHours\":0.000000,\"pvCost\":0.000000,\"pvs\":null,\"pvCostAdjustment\":0.000000,\"ramBytes\":146761671.651553,\"ramByteRequestAverage\":146761671.651553,\"ramByteUsageAverage\":125495250.508328,\"ramByteHours\":7042690751.326794,\"ramCost\":0.016647,\"ramCostAdjustment\":0.000000,\"ramEfficiency\":0.855096,\"sharedCost\":0.000000,\"externalCost\":0.000000,\"totalCost\":0.425469,\"totalEfficiency\":0.053569,\"rawAllocationOnly\":null},\"opencost\":{\"name\":\"opencost\",\"properties\":{\"cluster\":\"cluster-one\",\"node\":\"ip-192-168-20-42.ap-southeast-2.compute.internal\",\"controller\":\"opencost\",\"controllerKind\":\"deployment\",\"namespace\":\"opencost\",\"pod\":\"opencost-75dc7dcc49-xdx5t\",\"providerID\":\"i-064548f89b9d35c11\"},\"window\":{\"start\":\"2023-01-18T11:38:45Z\",\"end\":\"2023-01-20T11:38:45Z\"},\"start\":\"2023-01-18T11:38:45Z\",\"end\":\"2023-01-20T11:38:00Z\",\"minutes\":2879.235705,\"cpuCores\":0.019995,\"cpuCoreRequestAverage\":0.019995,\"cpuCoreUsageAverage\":0.001821,\"cpuCoreHours\":0.959490,\"cpuCost\":0.018170,\"cpuCostAdjustment\":0.000000,\"cpuEfficiency\":0.091055,\"gpuCount\":0.000000,\"gpuHours\":0.000000,\"gpuCost\":0.000000,\"gpuCostAdjustment\":0.000000,\"networkTransferBytes\":0.000000,\"networkReceiveBytes\":0.000000,\"networkCost\":0.000000,\"networkCostAdjustment\":0.000000,\"loadBalancerCost\":0.000000,\"loadBalancerCostAdjustment\":0.000000,\"pvBytes\":0.000000,\"pvByteHours\":0.000000,\"pvCost\":0.000000,\"pvs\":null,\"pvCostAdjustment\":0.000000,\"ramBytes\":109970800.411162,\"ramByteRequestAverage\":109970800.411162,\"ramByteUsageAverage\":35525920.971352,\"ramByteHours\":5277197583.375299,\"ramCost\":0.012474,\"ramCostAdjustment\":0.000000,\"ramEfficiency\":0.323049,\"sharedCost\":0.000000,\"externalCost\":0.000000,\"totalCost\":0.030644,\"totalEfficiency\":0.185490,\"rawAllocationOnly\":null},\"prometheus\":{\"name\":\"prometheus\",\"properties\":{\"cluster\":\"cluster-one\",\"namespace\":\"prometheus\"},\"window\":{\"start\":\"2023-01-18T11:38:45Z\",\"end\":\"2023-01-20T11:38:45Z\"},\"start\":\"2023-01-18T11:38:45Z\",\"end\":\"2023-01-20T11:38:00Z\",\"minutes\":2879.235705,\"cpuCores\":0.000000,\"cpuCoreRequestAverage\":0.000000,\"cpuCoreUsageAverage\":0.007793,\"cpuCoreHours\":0.000000,\"cpuCost\":0.000000,\"cpuCostAdjustment\":0.000000,\"cpuEfficiency\":0.000000,\"gpuCount\":0.000000,\"gpuHours\":0.000000,\"gpuCost\":0.000000,\"gpuCostAdjustment\":0.000000,\"networkTransferBytes\":0.000000,\"networkReceiveBytes\":0.000000,\"networkCost\":0.000000,\"networkCostAdjustment\":0.000000,\"loadBalancerCost\":0.000000,\"loadBalancerCostAdjustment\":0.000000,\"pvBytes\":0.000000,\"pvByteHours\":0.000000,\"pvCost\":0.000000,\"pvs\":null,\"pvCostAdjustment\":0.000000,\"ramBytes\":0.000000,\"ramByteRequestAverage\":0.000000,\"ramByteUsageAverage\":287770105.329488,\"ramByteHours\":0.000000,\"ramCost\":0.000000,\"ramCostAdjustment\":0.000000,\"ramEfficiency\":0.000000,\"sharedCost\":0.000000,\"externalCost\":0.000000,\"totalCost\":0.000000,\"totalEfficiency\":0.000000,\"rawAllocationOnly\":null}}]}"
- }
- }
- }
- }
- }
- }
- }
- }
- },
- "components": {
- "schemas": {
- "inline_response_200": {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer"
- },
- "data": {
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "opencost": {
- "type": "object",
- "properties": {
- "cpuCoreHours": {
- "type": "number"
- },
- "gpuCostAdjustment": {
- "type": "number"
- },
- "ramEfficiency": {
- "type": "number"
- },
- "loadBalancerCost": {
- "type": "number"
- },
- "gpuCost": {
- "type": "number"
- },
- "networkTransferBytes": {
- "type": "number"
- },
- "sharedCost": {
- "type": "number"
- },
- "pvCost": {
- "type": "number"
- },
- "totalEfficiency": {
- "type": "number"
- },
- "ramCostAdjustment": {
- "type": "number"
- },
- "pvByteHours": {
- "type": "number"
- },
- "networkCost": {
- "type": "number"
- },
- "ramByteUsageAverage": {
- "type": "number"
- },
- "end": {
- "type": "string"
- },
- "ramByteHours": {
- "type": "number"
- },
- "cpuCoreUsageAverage": {
- "type": "number"
- },
- "gpuCount": {
- "type": "number"
- },
- "cpuCostAdjustment": {
- "type": "number"
- },
- "externalCost": {
- "type": "number"
- },
- "minutes": {
- "type": "number"
- },
- "gpuHours": {
- "type": "number"
- },
- "loadBalancerCostAdjustment": {
- "type": "number"
- },
- "pvCostAdjustment": {
- "type": "number"
- },
- "ramCost": {
- "type": "number"
- },
- "start": {
- "type": "string"
- },
- "pvs": {},
- "cpuCost": {
- "type": "number"
- },
- "ramBytes": {
- "type": "number"
- },
- "networkCostAdjustment": {
- "type": "number"
- },
- "cpuCores": {
- "type": "number"
- },
- "pvBytes": {
- "type": "number"
- },
- "cpuEfficiency": {
- "type": "number"
- },
- "rawAllocationOnly": {},
- "name": {
- "type": "string"
- },
- "cpuCoreRequestAverage": {
- "type": "number"
- },
- "networkReceiveBytes": {
- "type": "number"
- },
- "window": {
- "type": "object",
- "properties": {
- "start": {
- "type": "string"
- },
- "end": {
- "type": "string"
- }
- }
- },
- "properties": {
- "type": "object",
- "properties": {
- "cluster": {
- "type": "string"
- },
- "node": {
- "type": "string"
- },
- "controller": {
- "type": "string"
- },
- "pod": {
- "type": "string"
- },
- "providerID": {
- "type": "string"
- },
- "namespace": {
- "type": "string"
- },
- "controllerKind": {
- "type": "string"
- }
- }
- },
- "totalCost": {
- "type": "number"
- },
- "ramByteRequestAverage": {
- "type": "number"
- }
- }
- },
- "kube-system": {
- "type": "object",
- "properties": {
- "cpuCoreHours": {
- "type": "number"
- },
- "gpuCostAdjustment": {
- "type": "number"
- },
- "ramEfficiency": {
- "type": "number"
- },
- "loadBalancerCost": {
- "type": "number"
- },
- "gpuCost": {
- "type": "number"
- },
- "networkTransferBytes": {
- "type": "number"
- },
- "sharedCost": {
- "type": "number"
- },
- "pvCost": {
- "type": "number"
- },
- "totalEfficiency": {
- "type": "number"
- },
- "ramCostAdjustment": {
- "type": "number"
- },
- "pvByteHours": {
- "type": "number"
- },
- "networkCost": {
- "type": "number"
- },
- "ramByteUsageAverage": {
- "type": "number"
- },
- "end": {
- "type": "string"
- },
- "ramByteHours": {
- "type": "number"
- },
- "cpuCoreUsageAverage": {
- "type": "number"
- },
- "gpuCount": {
- "type": "number"
- },
- "cpuCostAdjustment": {
- "type": "number"
- },
- "externalCost": {
- "type": "number"
- },
- "minutes": {
- "type": "number"
- },
- "gpuHours": {
- "type": "number"
- },
- "loadBalancerCostAdjustment": {
- "type": "number"
- },
- "pvCostAdjustment": {
- "type": "number"
- },
- "ramCost": {
- "type": "number"
- },
- "start": {
- "type": "string"
- },
- "pvs": {},
- "cpuCost": {
- "type": "number"
- },
- "ramBytes": {
- "type": "number"
- },
- "networkCostAdjustment": {
- "type": "number"
- },
- "cpuCores": {
- "type": "number"
- },
- "pvBytes": {
- "type": "number"
- },
- "cpuEfficiency": {
- "type": "number"
- },
- "rawAllocationOnly": {},
- "name": {
- "type": "string"
- },
- "cpuCoreRequestAverage": {
- "type": "number"
- },
- "networkReceiveBytes": {
- "type": "number"
- },
- "window": {
- "type": "object",
- "properties": {
- "start": {
- "type": "string"
- },
- "end": {
- "type": "string"
- }
- }
- },
- "properties": {
- "type": "object",
- "properties": {
- "cluster": {
- "type": "string"
- },
- "namespace": {
- "type": "string"
- }
- }
- },
- "totalCost": {
- "type": "number"
- },
- "ramByteRequestAverage": {
- "type": "number"
- }
- }
- },
- "prometheus": {
- "type": "object",
- "properties": {
- "cpuCoreHours": {
- "type": "number"
- },
- "gpuCostAdjustment": {
- "type": "number"
- },
- "ramEfficiency": {
- "type": "number"
- },
- "loadBalancerCost": {
- "type": "number"
- },
- "gpuCost": {
- "type": "number"
- },
- "networkTransferBytes": {
- "type": "number"
- },
- "sharedCost": {
- "type": "number"
- },
- "pvCost": {
- "type": "number"
- },
- "totalEfficiency": {
- "type": "number"
- },
- "ramCostAdjustment": {
- "type": "number"
- },
- "pvByteHours": {
- "type": "number"
- },
- "networkCost": {
- "type": "number"
- },
- "ramByteUsageAverage": {
- "type": "number"
- },
- "end": {
- "type": "string"
- },
- "ramByteHours": {
- "type": "number"
- },
- "cpuCoreUsageAverage": {
- "type": "number"
- },
- "gpuCount": {
- "type": "number"
- },
- "cpuCostAdjustment": {
- "type": "number"
- },
- "externalCost": {
- "type": "number"
- },
- "minutes": {
- "type": "number"
- },
- "gpuHours": {
- "type": "number"
- },
- "loadBalancerCostAdjustment": {
- "type": "number"
- },
- "pvCostAdjustment": {
- "type": "number"
- },
- "ramCost": {
- "type": "number"
- },
- "start": {
- "type": "string"
- },
- "pvs": {},
- "cpuCost": {
- "type": "number"
- },
- "ramBytes": {
- "type": "number"
- },
- "networkCostAdjustment": {
- "type": "number"
- },
- "cpuCores": {
- "type": "number"
- },
- "pvBytes": {
- "type": "number"
- },
- "cpuEfficiency": {
- "type": "number"
- },
- "rawAllocationOnly": {},
- "name": {
- "type": "string"
- },
- "cpuCoreRequestAverage": {
- "type": "number"
- },
- "networkReceiveBytes": {
- "type": "number"
- },
- "window": {
- "type": "object",
- "properties": {
- "start": {
- "type": "string"
- },
- "end": {
- "type": "string"
- }
- }
- },
- "properties": {
- "type": "object",
- "properties": {
- "cluster": {
- "type": "string"
- },
- "namespace": {
- "type": "string"
- }
- }
- },
- "totalCost": {
- "type": "number"
- },
- "ramByteRequestAverage": {
- "type": "number"
- }
- }
- }
- }
- }
- },
- "status": {
- "type": "string"
- }
- }
- }
- }
- }
- }
|