| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- {
- "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": "1.0.0"
- },
- "servers": [
- {
- "url": "http://localhost:9003",
- "description": "kubectl port-forward --namespace opencost service/opencost 9003"
- }
- ],
- "paths": {
- "/allocation": {
- "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. Note that 'data' is an array of sets (one per 'step').\n",
- "parameters": [
- {
- "name": "window",
- "in": "query",
- "required": true,
- "description": "Duration of time over which to query. Accepts: words like `today`, `lastweek`; durations like `30m`, `7d`; RFC3339 date pairs; or Unix timestamps.",
- "schema": {
- "type": "string"
- },
- "examples": {
- "today": {
- "value": "today"
- },
- "lastweek": {
- "value": "lastweek"
- },
- "range": {
- "value": "2024-01-01T00:00:00Z,2024-01-02T00:00:00Z"
- }
- }
- },
- {
- "name": "aggregate",
- "in": "query",
- "description": "Field by which to aggregate. e.g., `namespace`, `controller`, `label:app`.",
- "schema": {
- "type": "string"
- },
- "example": "namespace"
- },
- {
- "name": "step",
- "in": "query",
- "description": "Duration of a single allocation set. Default is `window`.",
- "schema": {
- "type": "string"
- },
- "example": "1d"
- },
- {
- "name": "accumulate",
- "in": "query",
- "description": "If true, sums the entire window into a single result set.",
- "schema": {
- "type": "boolean"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "Success",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/AllocationResponse"
- }
- }
- }
- }
- }
- }
- },
- "/assets": {
- "get": {
- "summary": "query for underlying infrastructure assets",
- "description": "Returns the costs of Nodes, Disks, and Load Balancers.",
- "parameters": [
- {
- "name": "window",
- "in": "query",
- "required": true,
- "schema": {
- "type": "string"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "Success",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/AssetsResponse"
- }
- }
- }
- }
- }
- }
- },
- "/cloudCost": {
- "get": {
- "summary": "query for cloud provider billing data",
- "description": "Retrieves non-K8s cloud provider costs via cloud integration.",
- "parameters": [
- {
- "name": "window",
- "in": "query",
- "required": true,
- "schema": {
- "type": "string"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "Success",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/CloudCostResponse"
- }
- }
- }
- }
- }
- }
- }
- },
- "components": {
- "schemas": {
- "AllocationResponse": {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer"
- },
- "status": {
- "type": "string"
- },
- "data": {
- "type": "array",
- "items": {
- "type": "object",
- "additionalProperties": {
- "$ref": "#/components/schemas/Allocation"
- }
- }
- }
- }
- },
- "Allocation": {
- "type": "object",
- "properties": {
- "name": {
- "type": "string"
- },
- "cpuCost": {
- "type": "number"
- },
- "cpuCoreUsageAverage": {
- "type": "number"
- },
- "ramCost": {
- "type": "number"
- },
- "ramByteUsageAverage": {
- "type": "number"
- },
- "pvCost": {
- "type": "number"
- },
- "networkCost": {
- "type": "number"
- },
- "sharedCost": {
- "type": "number"
- },
- "externalCost": {
- "type": "number"
- },
- "totalCost": {
- "type": "number"
- },
- "minutes": {
- "type": "number"
- },
- "window": {
- "type": "object",
- "properties": {
- "start": {
- "type": "string",
- "format": "date-time"
- },
- "end": {
- "type": "string",
- "format": "date-time"
- }
- }
- },
- "properties": {
- "type": "object",
- "additionalProperties": {
- "type": "string"
- }
- }
- }
- },
- "AssetsResponse": {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer"
- },
- "status": {
- "type": "string"
- },
- "data": {
- "type": "object",
- "additionalProperties": {
- "$ref": "#/components/schemas/Asset"
- }
- }
- }
- },
- "Asset": {
- "type": "object",
- "properties": {
- "type": {
- "type": "string"
- },
- "totalCost": {
- "type": "number"
- },
- "cpuCost": {
- "type": "number"
- },
- "ramCost": {
- "type": "number"
- },
- "providerID": {
- "type": "string"
- },
- "window": {
- "type": "object",
- "properties": {
- "start": {
- "type": "string",
- "format": "date-time"
- },
- "end": {
- "type": "string",
- "format": "date-time"
- }
- }
- }
- }
- },
- "CloudCostResponse": {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer"
- },
- "status": {
- "type": "string"
- },
- "data": {
- "type": "object",
- "properties": {
- "sets": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/CloudCostSet"
- }
- }
- }
- }
- }
- },
- "CloudCostSet": {
- "type": "object",
- "properties": {
- "cloudCosts": {
- "type": "object",
- "additionalProperties": {
- "$ref": "#/components/schemas/CloudCostItem"
- }
- }
- }
- },
- "CloudCostItem": {
- "type": "object",
- "properties": {
- "netCost": {
- "type": "object",
- "properties": {
- "cost": {
- "type": "number"
- }
- }
- }
- }
- }
- }
- }
- }
|