diff --git a/docs/integrations/api-examples.md b/docs/integrations/api-examples.md index 6cfbcca..35c701e 100644 --- a/docs/integrations/api-examples.md +++ b/docs/integrations/api-examples.md @@ -54,7 +54,7 @@ curl -G http://localhost:9003/allocation \ curl -G http://localhost:9003/allocation/compute \ -d window=9d \ -d step=3d \ - -d resolution=10m + -d resolution=10m \ -d aggregate=namespace ``` @@ -81,6 +81,26 @@ curl -G http://localhost:9003/allocation/compute \ } ``` + +### Allocation data with distributed idle costs + +Here's an example of an OpenCost API query that distributes cluster idle costs across all allocations in the cluster: + +```sh +curl -G http://localhost:9003/allocation \ + -d window=1d \ + -d shareIdle=true +``` + +Here's the same query, but distributing the idle costs of each *node* across all allocations on that node: + +```sh +curl -G http://localhost:9003/allocation \ + -d window=1d \ + -d shareIdle=true \ + -d idleByNode=true +``` + ## `/cloudCost` Examples The OpenCost `/cloudCost` API has query parameters for `window`, `aggregate`, and `filter`. Below are several examples of queries using this API. Please refer to the [OpenCost API](api#cloudcost) for the full API specifics. diff --git a/docs/integrations/api.md b/docs/integrations/api.md index 6a5893f..ceb1d74 100644 --- a/docs/integrations/api.md +++ b/docs/integrations/api.md @@ -13,7 +13,7 @@ Examples using the API endpoints are provided in the [API Examples](api-examples ## Allocation API -The standard OpenCost API query for costs and resources allocated to Kubernetes workloads based on on-demand list pricing. You may specify the `window` date range, the Kubernetes primitive(s) to `aggregate` on, the `step` for the duration of returned sets, the `resolution` for the duration to use for Prometheus queries, and `includeIdle` for whether to include the `__idle__` usage for the cluster. +The standard OpenCost API query for costs and resources allocated to Kubernetes workloads based on on-demand list pricing. You may specify the `window` date range, the Kubernetes primitive(s) to `aggregate` on, the `step` for the duration of returned sets, the `resolution` for the duration to use for Prometheus queries, `includeIdle` for whether to include the `__idle__` usage for the cluster, `shareIdle` for whether to distribute idle costs across non-idle allocations, and `idleByNode` for whether to calculate idle costs per node instead of per cluster. ### `/allocation` QUERY PARAMETERS @@ -102,7 +102,7 @@ QUERY PARAMETERS - Whether to return the calculated __idle__ field for the query. Default is false. + Whether to return the calculated \_\_idle\_\_ field for the query. Default is false.

Examples:
+ + shareIdle + boolean + + + + + Whether to distribute idle costs across non-idle allocations. Default is false. + + When disabled, idle costs are allocated to a separate \_\_idle\_\_ allocation. + When enabled, idle costs are distributed across non-idle allocations. This happens proportionally to the non-idle costs of each allocation. For example, if one allocation has twice as much non-idle costs as another, it also receives twice the amount of idle costs. This calculation happens separately for each resource (like CPU or RAM). + + You can choose to distribute idle costs per cluster or per node using the idleByNode parameter. + +

+ Examples:
+ + + + + idleByNode + boolean + + + + + Whether to calculate idle costs per node instead of per cluster. Default is false. +

+ Examples:
+ + + ## Cloud Costs API diff --git a/package-lock.json b/package-lock.json index 7e25c19..e0ee1a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,15 +15,15 @@ "autoprefixer": "^10.4.7", "clsx": "^2.0.0", "core-js": "^3.27.2", - "mobx": "^6.13.0", + "mobx": "^6.13.1", "postcss": "^8.4.39", "prism-react-renderer": "^2.3.0", "react": "^18.0.0", "react-dom": "^18.0.0", "react-github-btn": "^1.3.0", "react-icons": "^5.2.1", - "styled-components": "^6.1.11", - "tailwindcss": "^3.4.0" + "styled-components": "^6.1.12", + "tailwindcss": "^3.4.6" }, "devDependencies": { "@docusaurus/module-type-aliases": "3.4.0", @@ -12526,9 +12526,9 @@ } }, "node_modules/mobx": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/mobx/-/mobx-6.13.0.tgz", - "integrity": "sha512-1laWODrBWmB7mDJ8EClCjUQTyLwJ0ydJgE4FtK7t9r3JnjXgc9OhmYs2P4RtHrY1co5+4T6cKP2UswX2SU29mA==", + "version": "6.13.1", + "resolved": "https://registry.npmjs.org/mobx/-/mobx-6.13.1.tgz", + "integrity": "sha512-ekLRxgjWJr8hVxj9ZKuClPwM/iHckx3euIJ3Np7zLVNtqJvfbbq7l370W/98C8EabdQ1pB5Jd3BbDWxJPNnaOg==", "funding": { "type": "opencollective", "url": "https://opencollective.com/mobx" @@ -16207,10 +16207,9 @@ } }, "node_modules/styled-components": { - "version": "6.1.11", - "resolved": "https://registry.npmjs.org/styled-components/-/styled-components-6.1.11.tgz", - "integrity": "sha512-Ui0jXPzbp1phYij90h12ksljKGqF8ncGx+pjrNPsSPhbUUjWT2tD1FwGo2LF6USCnbrsIhNngDfodhxbegfEOA==", - "license": "MIT", + "version": "6.1.12", + "resolved": "https://registry.npmjs.org/styled-components/-/styled-components-6.1.12.tgz", + "integrity": "sha512-n/O4PzRPhbYI0k1vKKayfti3C/IGcPf+DqcrOB7O/ab9x4u/zjqraneT5N45+sIe87cxrCApXM8Bna7NYxwoTA==", "dependencies": { "@emotion/is-prop-valid": "1.2.2", "@emotion/unitless": "0.8.1", @@ -16431,10 +16430,9 @@ } }, "node_modules/tailwindcss": { - "version": "3.4.4", - "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.4.tgz", - "integrity": "sha512-ZoyXOdJjISB7/BcLTR6SEsLgKtDStYyYZVLsUtWChO4Ps20CBad7lfJKVDiejocV4ME1hLmyY0WJE3hSDcmQ2A==", - "license": "MIT", + "version": "3.4.6", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.6.tgz", + "integrity": "sha512-1uRHzPB+Vzu57ocybfZ4jh5Q3SdlH7XW23J5sQoM9LhE9eIOlzxer/3XPSsycvih3rboRsvt0QCmzSrqyOYUIA==", "dependencies": { "@alloc/quick-lru": "^5.2.0", "arg": "^5.0.2", diff --git a/package.json b/package.json index e908858..22f9099 100644 --- a/package.json +++ b/package.json @@ -25,12 +25,12 @@ "@mdx-js/react": "^3.0.0", "autoprefixer": "^10.4.7", "core-js": "^3.27.2", - "mobx": "^6.13.0", + "mobx": "^6.13.1", "postcss": "^8.4.39", "react-github-btn": "^1.3.0", "react-icons": "^5.2.1", - "styled-components": "^6.1.11", - "tailwindcss": "^3.4.0" + "styled-components": "^6.1.12", + "tailwindcss": "^3.4.6" }, "devDependencies": { "@docusaurus/module-type-aliases": "3.4.0",