swagger.json 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  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": "resolution",
  116. "in": "query",
  117. "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`",
  118. "required": false,
  119. "style": "form",
  120. "explode": true,
  121. "schema": {
  122. "type": "string"
  123. },
  124. "examples": {
  125. "1m": {
  126. "summary": "Highly accurate, slower query.",
  127. "value": "1m"
  128. },
  129. "30m": {
  130. "summary": "Less accurate, faster query. Not recommended for short-lived workloads ",
  131. "value": "30m"
  132. },
  133. }
  134. },
  135. ],
  136. "responses": {
  137. "200": {
  138. "description": "Auto generated using Swagger Inspector",
  139. "content": {
  140. "application/json": {
  141. "schema": {
  142. "$ref": "#/components/schemas/inline_response_200"
  143. },
  144. "examples": {
  145. "0": {
  146. "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}}]}"
  147. }
  148. }
  149. }
  150. }
  151. }
  152. }
  153. }
  154. }
  155. },
  156. "components": {
  157. "schemas": {
  158. "inline_response_200": {
  159. "type": "object",
  160. "properties": {
  161. "code": {
  162. "type": "integer"
  163. },
  164. "data": {
  165. "type": "array",
  166. "items": {
  167. "type": "object",
  168. "properties": {
  169. "app=prometheus": {
  170. "type": "object",
  171. "properties": {
  172. "cpuCoreHours": {
  173. "type": "number"
  174. },
  175. "gpuCostAdjustment": {
  176. "type": "number"
  177. },
  178. "ramEfficiency": {
  179. "type": "number"
  180. },
  181. "loadBalancerCost": {
  182. "type": "number"
  183. },
  184. "gpuCost": {
  185. "type": "number"
  186. },
  187. "networkTransferBytes": {
  188. "type": "number"
  189. },
  190. "sharedCost": {
  191. "type": "number"
  192. },
  193. "pvCost": {
  194. "type": "number"
  195. },
  196. "totalEfficiency": {
  197. "type": "number"
  198. },
  199. "ramCostAdjustment": {
  200. "type": "number"
  201. },
  202. "pvByteHours": {
  203. "type": "number"
  204. },
  205. "networkCost": {
  206. "type": "number"
  207. },
  208. "ramByteUsageAverage": {
  209. "type": "number"
  210. },
  211. "end": {
  212. "type": "string"
  213. },
  214. "ramByteHours": {
  215. "type": "number"
  216. },
  217. "cpuCoreUsageAverage": {
  218. "type": "number"
  219. },
  220. "gpuCount": {
  221. "type": "number"
  222. },
  223. "cpuCostAdjustment": {
  224. "type": "number"
  225. },
  226. "externalCost": {
  227. "type": "number"
  228. },
  229. "minutes": {
  230. "type": "number"
  231. },
  232. "gpuHours": {
  233. "type": "number"
  234. },
  235. "loadBalancerCostAdjustment": {
  236. "type": "number"
  237. },
  238. "pvCostAdjustment": {
  239. "type": "number"
  240. },
  241. "ramCost": {
  242. "type": "number"
  243. },
  244. "start": {
  245. "type": "string"
  246. },
  247. "pvs": {},
  248. "cpuCost": {
  249. "type": "number"
  250. },
  251. "ramBytes": {
  252. "type": "number"
  253. },
  254. "networkCostAdjustment": {
  255. "type": "number"
  256. },
  257. "cpuCores": {
  258. "type": "number"
  259. },
  260. "pvBytes": {
  261. "type": "number"
  262. },
  263. "cpuEfficiency": {
  264. "type": "number"
  265. },
  266. "rawAllocationOnly": {},
  267. "name": {
  268. "type": "string"
  269. },
  270. "cpuCoreRequestAverage": {
  271. "type": "number"
  272. },
  273. "networkReceiveBytes": {
  274. "type": "number"
  275. },
  276. "window": {
  277. "type": "object",
  278. "properties": {
  279. "start": {
  280. "type": "string"
  281. },
  282. "end": {
  283. "type": "string"
  284. }
  285. }
  286. },
  287. "properties": {
  288. "type": "object",
  289. "properties": {
  290. "cluster": {
  291. "type": "string"
  292. },
  293. "node": {
  294. "type": "string"
  295. },
  296. "controller": {
  297. "type": "string"
  298. },
  299. "pod": {
  300. "type": "string"
  301. },
  302. "providerID": {
  303. "type": "string"
  304. },
  305. "namespace": {
  306. "type": "string"
  307. },
  308. "controllerKind": {
  309. "type": "string"
  310. }
  311. }
  312. },
  313. "totalCost": {
  314. "type": "number"
  315. },
  316. "ramByteRequestAverage": {
  317. "type": "number"
  318. }
  319. }
  320. },
  321. "app=opencost": {
  322. "type": "object",
  323. "properties": {
  324. "cpuCoreHours": {
  325. "type": "number"
  326. },
  327. "gpuCostAdjustment": {
  328. "type": "number"
  329. },
  330. "ramEfficiency": {
  331. "type": "number"
  332. },
  333. "loadBalancerCost": {
  334. "type": "number"
  335. },
  336. "gpuCost": {
  337. "type": "number"
  338. },
  339. "networkTransferBytes": {
  340. "type": "number"
  341. },
  342. "sharedCost": {
  343. "type": "number"
  344. },
  345. "pvCost": {
  346. "type": "number"
  347. },
  348. "totalEfficiency": {
  349. "type": "number"
  350. },
  351. "ramCostAdjustment": {
  352. "type": "number"
  353. },
  354. "pvByteHours": {
  355. "type": "number"
  356. },
  357. "networkCost": {
  358. "type": "number"
  359. },
  360. "ramByteUsageAverage": {
  361. "type": "number"
  362. },
  363. "end": {
  364. "type": "string"
  365. },
  366. "ramByteHours": {
  367. "type": "number"
  368. },
  369. "cpuCoreUsageAverage": {
  370. "type": "number"
  371. },
  372. "gpuCount": {
  373. "type": "number"
  374. },
  375. "cpuCostAdjustment": {
  376. "type": "number"
  377. },
  378. "externalCost": {
  379. "type": "number"
  380. },
  381. "minutes": {
  382. "type": "number"
  383. },
  384. "gpuHours": {
  385. "type": "number"
  386. },
  387. "loadBalancerCostAdjustment": {
  388. "type": "number"
  389. },
  390. "pvCostAdjustment": {
  391. "type": "number"
  392. },
  393. "ramCost": {
  394. "type": "number"
  395. },
  396. "start": {
  397. "type": "string"
  398. },
  399. "pvs": {},
  400. "cpuCost": {
  401. "type": "number"
  402. },
  403. "ramBytes": {
  404. "type": "number"
  405. },
  406. "networkCostAdjustment": {
  407. "type": "number"
  408. },
  409. "cpuCores": {
  410. "type": "number"
  411. },
  412. "pvBytes": {
  413. "type": "number"
  414. },
  415. "cpuEfficiency": {
  416. "type": "number"
  417. },
  418. "rawAllocationOnly": {},
  419. "name": {
  420. "type": "string"
  421. },
  422. "cpuCoreRequestAverage": {
  423. "type": "number"
  424. },
  425. "networkReceiveBytes": {
  426. "type": "number"
  427. },
  428. "window": {
  429. "type": "object",
  430. "properties": {
  431. "start": {
  432. "type": "string"
  433. },
  434. "end": {
  435. "type": "string"
  436. }
  437. }
  438. },
  439. "properties": {
  440. "type": "object",
  441. "properties": {
  442. "cluster": {
  443. "type": "string"
  444. },
  445. "node": {
  446. "type": "string"
  447. },
  448. "controller": {
  449. "type": "string"
  450. },
  451. "pod": {
  452. "type": "string"
  453. },
  454. "providerID": {
  455. "type": "string"
  456. },
  457. "namespace": {
  458. "type": "string"
  459. },
  460. "controllerKind": {
  461. "type": "string"
  462. }
  463. }
  464. },
  465. "totalCost": {
  466. "type": "number"
  467. },
  468. "ramByteRequestAverage": {
  469. "type": "number"
  470. }
  471. }
  472. },
  473. "__unallocated__": {
  474. "type": "object",
  475. "properties": {
  476. "cpuCoreHours": {
  477. "type": "number"
  478. },
  479. "gpuCostAdjustment": {
  480. "type": "number"
  481. },
  482. "ramEfficiency": {
  483. "type": "number"
  484. },
  485. "loadBalancerCost": {
  486. "type": "number"
  487. },
  488. "gpuCost": {
  489. "type": "number"
  490. },
  491. "networkTransferBytes": {
  492. "type": "number"
  493. },
  494. "sharedCost": {
  495. "type": "number"
  496. },
  497. "pvCost": {
  498. "type": "number"
  499. },
  500. "totalEfficiency": {
  501. "type": "number"
  502. },
  503. "ramCostAdjustment": {
  504. "type": "number"
  505. },
  506. "pvByteHours": {
  507. "type": "number"
  508. },
  509. "networkCost": {
  510. "type": "number"
  511. },
  512. "ramByteUsageAverage": {
  513. "type": "number"
  514. },
  515. "end": {
  516. "type": "string"
  517. },
  518. "ramByteHours": {
  519. "type": "number"
  520. },
  521. "cpuCoreUsageAverage": {
  522. "type": "number"
  523. },
  524. "gpuCount": {
  525. "type": "number"
  526. },
  527. "cpuCostAdjustment": {
  528. "type": "number"
  529. },
  530. "externalCost": {
  531. "type": "number"
  532. },
  533. "minutes": {
  534. "type": "number"
  535. },
  536. "gpuHours": {
  537. "type": "number"
  538. },
  539. "loadBalancerCostAdjustment": {
  540. "type": "number"
  541. },
  542. "pvCostAdjustment": {
  543. "type": "number"
  544. },
  545. "ramCost": {
  546. "type": "number"
  547. },
  548. "start": {
  549. "type": "string"
  550. },
  551. "pvs": {},
  552. "cpuCost": {
  553. "type": "number"
  554. },
  555. "ramBytes": {
  556. "type": "number"
  557. },
  558. "networkCostAdjustment": {
  559. "type": "number"
  560. },
  561. "cpuCores": {
  562. "type": "number"
  563. },
  564. "pvBytes": {
  565. "type": "number"
  566. },
  567. "cpuEfficiency": {
  568. "type": "number"
  569. },
  570. "rawAllocationOnly": {},
  571. "name": {
  572. "type": "string"
  573. },
  574. "cpuCoreRequestAverage": {
  575. "type": "number"
  576. },
  577. "networkReceiveBytes": {
  578. "type": "number"
  579. },
  580. "window": {
  581. "type": "object",
  582. "properties": {
  583. "start": {
  584. "type": "string"
  585. },
  586. "end": {
  587. "type": "string"
  588. }
  589. }
  590. },
  591. "properties": {
  592. "type": "object",
  593. "properties": {
  594. "cluster": {
  595. "type": "string"
  596. }
  597. }
  598. },
  599. "totalCost": {
  600. "type": "number"
  601. },
  602. "ramByteRequestAverage": {
  603. "type": "number"
  604. }
  605. }
  606. }
  607. }
  608. }
  609. },
  610. "status": {
  611. "type": "string"
  612. }
  613. }
  614. }
  615. }
  616. }
  617. }