| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618 |
- {
- "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 `aggregate` on, ",
- "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: `cluster`, `namespace`, `controllerKind`, `controller`, `service`, `label:<name>`, and `annotation:<name>`. Also accepts comma-separated lists for multi-aggregation, like `namespace,label:app`.",
- "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"
- },
- }
- },
- {
- "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": "Auto generated using Swagger Inspector",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/inline_response_200"
- },
- "examples": {
- "0": {
- "value": "{\"code\":200,\"status\":\"success\",\"data\":[{\"__unallocated__\":{\"name\":\"__unallocated__\",\"properties\":{\"cluster\":\"cluster-one\"},\"window\":{\"start\":\"2023-01-19T00:00:00Z\",\"end\":\"2023-01-20T00:00:00Z\"},\"start\":\"2023-01-19T00:00:00Z\",\"end\":\"2023-01-19T06:16:00Z\",\"minutes\":376.000000,\"cpuCores\":0.450000,\"cpuCoreRequestAverage\":0.450000,\"cpuCoreUsageAverage\":0.002906,\"cpuCoreHours\":2.820000,\"cpuCost\":0.053402,\"cpuCostAdjustment\":0.000000,\"cpuEfficiency\":0.006458,\"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\":146800640.000000,\"ramByteRequestAverage\":146800640.000000,\"ramByteUsageAverage\":167022404.312668,\"ramByteHours\":919950677.333333,\"ramCost\":0.002174,\"ramCostAdjustment\":0.000000,\"ramEfficiency\":1.137750,\"sharedCost\":0.000000,\"externalCost\":0.000000,\"totalCost\":0.055577,\"totalEfficiency\":0.050720,\"rawAllocationOnly\":null},\"app=opencost\":{\"name\":\"app=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-19T00:00:00Z\",\"end\":\"2023-01-20T00:00:00Z\"},\"start\":\"2023-01-19T00:00:00Z\",\"end\":\"2023-01-19T06:16:00Z\",\"minutes\":376.000000,\"cpuCores\":0.020000,\"cpuCoreRequestAverage\":0.020000,\"cpuCoreUsageAverage\":0.000535,\"cpuCoreHours\":0.125333,\"cpuCost\":0.002373,\"cpuCostAdjustment\":0.000000,\"cpuEfficiency\":0.026742,\"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\":110000000.000000,\"ramByteRequestAverage\":110000000.000000,\"ramByteUsageAverage\":35962990.404313,\"ramByteHours\":689333333.333333,\"ramCost\":0.001629,\"ramCostAdjustment\":0.000000,\"ramEfficiency\":0.326936,\"sharedCost\":0.000000,\"externalCost\":0.000000,\"totalCost\":0.004003,\"totalEfficiency\":0.148938,\"rawAllocationOnly\":null},\"app=prometheus\":{\"name\":\"app=prometheus\",\"properties\":{\"cluster\":\"cluster-one\",\"node\":\"ip-192-168-94-25.ap-southeast-2.compute.internal\",\"controller\":\"my-prometheus-server\",\"controllerKind\":\"deployment\",\"namespace\":\"prometheus\",\"pod\":\"my-prometheus-server-57787bd6bf-f9lkd\",\"providerID\":\"i-06555520a3af0b7f2\"},\"window\":{\"start\":\"2023-01-19T00:00:00Z\",\"end\":\"2023-01-20T00:00:00Z\"},\"start\":\"2023-01-19T00:00:00Z\",\"end\":\"2023-01-19T06:16:00Z\",\"minutes\":376.000000,\"cpuCores\":0.000000,\"cpuCoreRequestAverage\":0.000000,\"cpuCoreUsageAverage\":0.001790,\"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\":241884819.665768,\"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": {
- "app=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"
- },
- "node": {
- "type": "string"
- },
- "controller": {
- "type": "string"
- },
- "pod": {
- "type": "string"
- },
- "providerID": {
- "type": "string"
- },
- "namespace": {
- "type": "string"
- },
- "controllerKind": {
- "type": "string"
- }
- }
- },
- "totalCost": {
- "type": "number"
- },
- "ramByteRequestAverage": {
- "type": "number"
- }
- }
- },
- "app=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"
- }
- }
- },
- "__unallocated__": {
- "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"
- }
- }
- },
- "totalCost": {
- "type": "number"
- },
- "ramByteRequestAverage": {
- "type": "number"
- }
- }
- }
- }
- }
- },
- "status": {
- "type": "string"
- }
- }
- }
- }
- }
- }
|