Allocation Trends API

Calculating trend value

The Trends API determines changes in resource cost usage over time based on the interval set window parameter and provides that information via the schema field value. Cost usage for the current window sampled will be compared with the previous window, the window directly before the current window of the same size interval. For example, for window=3d, Kubecost will output cost usage for the past three days compared to cost usage of the three days before the start of the window. This means a total of six days of allocation are sampled in order to provide an accurate value.
The equation for calculating value is:
value=current/previous - 1
Receiving a positive value means your more recent totalCost has increased compared to the previous window. A negative value means spending has decreased.
It's important to recognize when a resource is not detected to exist in the previous window. This is designated by the field IsInfinite=true, which means the allocation could not be determined to exist. Otherwise, the cause of an unexpected or major trend change could be misattributed.
In the example output below, value is expressed as 0.11... meaning spending has increased in the current window by roughly 11% from the previous window.
"etl-mount": {
"trends": {
"costs": {
"totalCost": {
"relativeChange": {
"isInfinite": false,
"value": 0.11111005449714528
Trend values are converted into percentages in the Kubecost UI. Go to the Allocations page, and manually apply any additional parameters. Trends will be presented in the rightmost column, next to your Total cost. The window parameter is determined by the date range icon in the top right of the page. The default is Last 7 days (window=7d). The equation value*100 is used to provide percentages.
Total cost column
Requests with large time intervals for window can result in an error. The recommended maximum interval for window is 7 days. A failed response will show a N/A inside a gray bubble in the UI with no percentage returned.
The Trends API does not currently support cost comparisons besides totalCost.