swagger.json 22 KB

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