swagger.json 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. {
  2. "openapi": "3.0.1",
  3. "info": {
  4. "title": "OpenCost API",
  5. "description": "The OpenCost API provides real-time and historical reporting of Kubernetes cloud costs.",
  6. "license": {
  7. "name": "Apache 2.0",
  8. "url": "https://www.apache.org/licenses/LICENSE-2.0.html"
  9. },
  10. "version": "0.1",
  11. },
  12. "servers": [
  13. {
  14. "url": "http://localhost:9003",
  15. "description": "kubectl port-forward --namespace opencost service/opencost 9003"
  16. },
  17. ],
  18. "paths": {
  19. "/allocation/compute": {
  20. "get": {
  21. "summary": "query for costs and resources allocated to Kubernetes workloads",
  22. "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, ",
  23. "parameters": [
  24. {
  25. "name": "window",
  26. "in": "query",
  27. "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`.",
  28. "required": true,
  29. "style": "form",
  30. "explode": true,
  31. "schema": {
  32. "type": "string"
  33. },
  34. "examples": {
  35. "today": {
  36. "summary": "The current day",
  37. "value": "today"
  38. },
  39. "month": {
  40. "summary": "The month-to-date",
  41. "value": "month"
  42. },
  43. "lastweek": {
  44. "summary": "The previous week",
  45. "value": "lastweek"
  46. },
  47. "30m": {
  48. "summary": "The last 30 minutes",
  49. "value": "30m"
  50. },
  51. "12h": {
  52. "summary": "The last 12 hours",
  53. "value": "12h"
  54. },
  55. "7d": {
  56. "summary": "The previous 7 days",
  57. "value": "7d"
  58. },
  59. "range": {
  60. "summary": "A custom RFC3339 date range",
  61. "value": "2023-01-18T10:30:00Z,2023-01-19T10:30:00Z"
  62. },
  63. "unix": {
  64. "summary": "A custom Unix timestamp range",
  65. "value": "1674073869,1674193869"
  66. }
  67. }
  68. },
  69. {
  70. "name": "aggregate",
  71. "in": "query",
  72. "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`.",
  73. "required": false,
  74. "style": "form",
  75. "explode": true,
  76. "schema": {
  77. "type": "string"
  78. },
  79. "examples": {
  80. "cluster": {
  81. "summary": "Aggregates by the cluster.",
  82. "value": "cluster"
  83. },
  84. "node": {
  85. "summary": "Aggregates by the compute nodes in the cluster.",
  86. "value": "node"
  87. },
  88. "namespace": {
  89. "summary": "Aggregates by the namespaces in the cluster.",
  90. "value": "namespace"
  91. },
  92. "controllerKind": {
  93. "summary": "Aggregates by the kinds of controllers present in the cluster.",
  94. "value": "controllerKind"
  95. },
  96. "controller": {
  97. "summary": "Aggregates by the individual controllers within the cluster.",
  98. "value": "controller"
  99. },
  100. "service": {
  101. "summary": "Aggregates by the services within the cluster.",
  102. "value": "service"
  103. },
  104. "pod": {
  105. "summary": "Aggregates by the individual pods within the cluster",
  106. "value": "pod"
  107. },
  108. "container": {
  109. "summary": "Aggregates by the containers present in the cluster",
  110. "value": "container"
  111. },
  112. }
  113. },
  114. {
  115. "name": "step",
  116. "in": "query",
  117. "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`",
  118. "required": false,
  119. "style": "form",
  120. "explode": true,
  121. "schema": {
  122. "type": "string"
  123. },
  124. "examples": {
  125. "30m": {
  126. "summary": "30 minute steps over the duration of the window.",
  127. "value": "30m"
  128. },
  129. "2h": {
  130. "summary": "2 hour steps over the duration of the window",
  131. "value": "2h"
  132. },
  133. "1d": {
  134. "summary": "Daily steps over the duration of the window (ie. `lastweek` or `month`",
  135. "value": "1d"
  136. },
  137. }
  138. },
  139. {
  140. "name": "resolution",
  141. "in": "query",
  142. "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`",
  143. "required": false,
  144. "style": "form",
  145. "explode": true,
  146. "schema": {
  147. "type": "string"
  148. },
  149. "examples": {
  150. "1m": {
  151. "summary": "Highly accurate, slower query.",
  152. "value": "1m"
  153. },
  154. "30m": {
  155. "summary": "Less accurate, faster query. Not recommended for short-lived workloads.",
  156. "value": "30m"
  157. },
  158. }
  159. },
  160. ],
  161. "responses": {
  162. "200": {
  163. "description": "Auto generated using Swagger Inspector",
  164. "content": {
  165. "application/json": {
  166. "schema": {
  167. "$ref": "#/components/schemas/inline_response_200"
  168. },
  169. "examples": {
  170. "0": {
  171. "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}}]}"
  172. }
  173. }
  174. }
  175. }
  176. }
  177. }
  178. }
  179. }
  180. },
  181. "components": {
  182. "schemas": {
  183. "inline_response_200": {
  184. "type": "object",
  185. "properties": {
  186. "code": {
  187. "type": "integer"
  188. },
  189. "data": {
  190. "type": "array",
  191. "items": {
  192. "type": "object",
  193. "properties": {
  194. "app=prometheus": {
  195. "type": "object",
  196. "properties": {
  197. "cpuCoreHours": {
  198. "type": "number"
  199. },
  200. "gpuCostAdjustment": {
  201. "type": "number"
  202. },
  203. "ramEfficiency": {
  204. "type": "number"
  205. },
  206. "loadBalancerCost": {
  207. "type": "number"
  208. },
  209. "gpuCost": {
  210. "type": "number"
  211. },
  212. "networkTransferBytes": {
  213. "type": "number"
  214. },
  215. "sharedCost": {
  216. "type": "number"
  217. },
  218. "pvCost": {
  219. "type": "number"
  220. },
  221. "totalEfficiency": {
  222. "type": "number"
  223. },
  224. "ramCostAdjustment": {
  225. "type": "number"
  226. },
  227. "pvByteHours": {
  228. "type": "number"
  229. },
  230. "networkCost": {
  231. "type": "number"
  232. },
  233. "ramByteUsageAverage": {
  234. "type": "number"
  235. },
  236. "end": {
  237. "type": "string"
  238. },
  239. "ramByteHours": {
  240. "type": "number"
  241. },
  242. "cpuCoreUsageAverage": {
  243. "type": "number"
  244. },
  245. "gpuCount": {
  246. "type": "number"
  247. },
  248. "cpuCostAdjustment": {
  249. "type": "number"
  250. },
  251. "externalCost": {
  252. "type": "number"
  253. },
  254. "minutes": {
  255. "type": "number"
  256. },
  257. "gpuHours": {
  258. "type": "number"
  259. },
  260. "loadBalancerCostAdjustment": {
  261. "type": "number"
  262. },
  263. "pvCostAdjustment": {
  264. "type": "number"
  265. },
  266. "ramCost": {
  267. "type": "number"
  268. },
  269. "start": {
  270. "type": "string"
  271. },
  272. "pvs": {},
  273. "cpuCost": {
  274. "type": "number"
  275. },
  276. "ramBytes": {
  277. "type": "number"
  278. },
  279. "networkCostAdjustment": {
  280. "type": "number"
  281. },
  282. "cpuCores": {
  283. "type": "number"
  284. },
  285. "pvBytes": {
  286. "type": "number"
  287. },
  288. "cpuEfficiency": {
  289. "type": "number"
  290. },
  291. "rawAllocationOnly": {},
  292. "name": {
  293. "type": "string"
  294. },
  295. "cpuCoreRequestAverage": {
  296. "type": "number"
  297. },
  298. "networkReceiveBytes": {
  299. "type": "number"
  300. },
  301. "window": {
  302. "type": "object",
  303. "properties": {
  304. "start": {
  305. "type": "string"
  306. },
  307. "end": {
  308. "type": "string"
  309. }
  310. }
  311. },
  312. "properties": {
  313. "type": "object",
  314. "properties": {
  315. "cluster": {
  316. "type": "string"
  317. },
  318. "node": {
  319. "type": "string"
  320. },
  321. "controller": {
  322. "type": "string"
  323. },
  324. "pod": {
  325. "type": "string"
  326. },
  327. "providerID": {
  328. "type": "string"
  329. },
  330. "namespace": {
  331. "type": "string"
  332. },
  333. "controllerKind": {
  334. "type": "string"
  335. }
  336. }
  337. },
  338. "totalCost": {
  339. "type": "number"
  340. },
  341. "ramByteRequestAverage": {
  342. "type": "number"
  343. }
  344. }
  345. },
  346. "app=opencost": {
  347. "type": "object",
  348. "properties": {
  349. "cpuCoreHours": {
  350. "type": "number"
  351. },
  352. "gpuCostAdjustment": {
  353. "type": "number"
  354. },
  355. "ramEfficiency": {
  356. "type": "number"
  357. },
  358. "loadBalancerCost": {
  359. "type": "number"
  360. },
  361. "gpuCost": {
  362. "type": "number"
  363. },
  364. "networkTransferBytes": {
  365. "type": "number"
  366. },
  367. "sharedCost": {
  368. "type": "number"
  369. },
  370. "pvCost": {
  371. "type": "number"
  372. },
  373. "totalEfficiency": {
  374. "type": "number"
  375. },
  376. "ramCostAdjustment": {
  377. "type": "number"
  378. },
  379. "pvByteHours": {
  380. "type": "number"
  381. },
  382. "networkCost": {
  383. "type": "number"
  384. },
  385. "ramByteUsageAverage": {
  386. "type": "number"
  387. },
  388. "end": {
  389. "type": "string"
  390. },
  391. "ramByteHours": {
  392. "type": "number"
  393. },
  394. "cpuCoreUsageAverage": {
  395. "type": "number"
  396. },
  397. "gpuCount": {
  398. "type": "number"
  399. },
  400. "cpuCostAdjustment": {
  401. "type": "number"
  402. },
  403. "externalCost": {
  404. "type": "number"
  405. },
  406. "minutes": {
  407. "type": "number"
  408. },
  409. "gpuHours": {
  410. "type": "number"
  411. },
  412. "loadBalancerCostAdjustment": {
  413. "type": "number"
  414. },
  415. "pvCostAdjustment": {
  416. "type": "number"
  417. },
  418. "ramCost": {
  419. "type": "number"
  420. },
  421. "start": {
  422. "type": "string"
  423. },
  424. "pvs": {},
  425. "cpuCost": {
  426. "type": "number"
  427. },
  428. "ramBytes": {
  429. "type": "number"
  430. },
  431. "networkCostAdjustment": {
  432. "type": "number"
  433. },
  434. "cpuCores": {
  435. "type": "number"
  436. },
  437. "pvBytes": {
  438. "type": "number"
  439. },
  440. "cpuEfficiency": {
  441. "type": "number"
  442. },
  443. "rawAllocationOnly": {},
  444. "name": {
  445. "type": "string"
  446. },
  447. "cpuCoreRequestAverage": {
  448. "type": "number"
  449. },
  450. "networkReceiveBytes": {
  451. "type": "number"
  452. },
  453. "window": {
  454. "type": "object",
  455. "properties": {
  456. "start": {
  457. "type": "string"
  458. },
  459. "end": {
  460. "type": "string"
  461. }
  462. }
  463. },
  464. "properties": {
  465. "type": "object",
  466. "properties": {
  467. "cluster": {
  468. "type": "string"
  469. },
  470. "node": {
  471. "type": "string"
  472. },
  473. "controller": {
  474. "type": "string"
  475. },
  476. "pod": {
  477. "type": "string"
  478. },
  479. "providerID": {
  480. "type": "string"
  481. },
  482. "namespace": {
  483. "type": "string"
  484. },
  485. "controllerKind": {
  486. "type": "string"
  487. }
  488. }
  489. },
  490. "totalCost": {
  491. "type": "number"
  492. },
  493. "ramByteRequestAverage": {
  494. "type": "number"
  495. }
  496. }
  497. },
  498. "__unallocated__": {
  499. "type": "object",
  500. "properties": {
  501. "cpuCoreHours": {
  502. "type": "number"
  503. },
  504. "gpuCostAdjustment": {
  505. "type": "number"
  506. },
  507. "ramEfficiency": {
  508. "type": "number"
  509. },
  510. "loadBalancerCost": {
  511. "type": "number"
  512. },
  513. "gpuCost": {
  514. "type": "number"
  515. },
  516. "networkTransferBytes": {
  517. "type": "number"
  518. },
  519. "sharedCost": {
  520. "type": "number"
  521. },
  522. "pvCost": {
  523. "type": "number"
  524. },
  525. "totalEfficiency": {
  526. "type": "number"
  527. },
  528. "ramCostAdjustment": {
  529. "type": "number"
  530. },
  531. "pvByteHours": {
  532. "type": "number"
  533. },
  534. "networkCost": {
  535. "type": "number"
  536. },
  537. "ramByteUsageAverage": {
  538. "type": "number"
  539. },
  540. "end": {
  541. "type": "string"
  542. },
  543. "ramByteHours": {
  544. "type": "number"
  545. },
  546. "cpuCoreUsageAverage": {
  547. "type": "number"
  548. },
  549. "gpuCount": {
  550. "type": "number"
  551. },
  552. "cpuCostAdjustment": {
  553. "type": "number"
  554. },
  555. "externalCost": {
  556. "type": "number"
  557. },
  558. "minutes": {
  559. "type": "number"
  560. },
  561. "gpuHours": {
  562. "type": "number"
  563. },
  564. "loadBalancerCostAdjustment": {
  565. "type": "number"
  566. },
  567. "pvCostAdjustment": {
  568. "type": "number"
  569. },
  570. "ramCost": {
  571. "type": "number"
  572. },
  573. "start": {
  574. "type": "string"
  575. },
  576. "pvs": {},
  577. "cpuCost": {
  578. "type": "number"
  579. },
  580. "ramBytes": {
  581. "type": "number"
  582. },
  583. "networkCostAdjustment": {
  584. "type": "number"
  585. },
  586. "cpuCores": {
  587. "type": "number"
  588. },
  589. "pvBytes": {
  590. "type": "number"
  591. },
  592. "cpuEfficiency": {
  593. "type": "number"
  594. },
  595. "rawAllocationOnly": {},
  596. "name": {
  597. "type": "string"
  598. },
  599. "cpuCoreRequestAverage": {
  600. "type": "number"
  601. },
  602. "networkReceiveBytes": {
  603. "type": "number"
  604. },
  605. "window": {
  606. "type": "object",
  607. "properties": {
  608. "start": {
  609. "type": "string"
  610. },
  611. "end": {
  612. "type": "string"
  613. }
  614. }
  615. },
  616. "properties": {
  617. "type": "object",
  618. "properties": {
  619. "cluster": {
  620. "type": "string"
  621. }
  622. }
  623. },
  624. "totalCost": {
  625. "type": "number"
  626. },
  627. "ramByteRequestAverage": {
  628. "type": "number"
  629. }
  630. }
  631. }
  632. }
  633. }
  634. },
  635. "status": {
  636. "type": "string"
  637. }
  638. }
  639. }
  640. }
  641. }
  642. }