Assets API

Assets API

GET http://<your-kubecost-address>/model/assets

The Assets API retrieves backing cost data broken down by individual assets in your cluster but also provides various aggregations of this data.

Path Parameters

NameTypeDescription

window*

string

Dictates the applicable window for measuring historical asset cost.

aggregate

string

Used to consolidate cost model data. Supported values are account, cluster, project, providerid, provider, and type. Passing an empty value for this parameter or none at all returns data by an individual asset. Supports multi-aggregation (aggregation of multiple categories) in a comma separated list, such as aggregate=account,project.

accumulate

boolean

When set to false, this endpoint returns daily time series data vs cumulative data. Default value is false.

disableAdjustments

boolean

When set to true, zeros out all adjustments from cloud provider reconciliation, which would otherwise change the totalCost. Default value is false.

format

string

When set to csv, will download an accumulated version of the asset results in CSV format. By default, results will be in JSON format.

filter

string

Filter your results by any category which you can aggregate by, can support multiple filterable items in the same category in a comma-separated list. For example, to filter results by clusters A and B, use filter=cluster:clusterA,clusterB See our Filter Parameters doc for a complete explanation of how to use filters and what categories are supported.

step

string

Duration of each individual data metric across the window. Accepts 1h, 1d, or 1w. If left blank, defaults to longest step duration available based on level of granularity of data represented by window.

  {
    cluster: "..."  // parent cluster for asset
    cpuCores: 1  // number of CPUs, given this is a node asset type
    cpuCost: 0.00 // cumulative cost of CPU measured over time window
    discount: 0.0 // discount applied to asset cost
    end: "2020-08-21T00:00:00+0000" // end of measured time window
    gpuCost: 0
    key: "..."
    name: "..."
    nodeType: "..."
    preemptible: 0
    providerID: "..."
    ramBytes: 0
    ramCost: 0.00
    start: "2020-08-20T00:00:00+0000"
    adjustment: 0.00 // amount added to totalCost during reconciliation with cloud provider data
    totalCost: 0.00 // total asset cost after applied discount
    type: "node" // e.g. node, disk, cluster management fee, etc
}

Assets API (Aggregator only)

GET http://<your-kubecost-address>/model/assets

The Assets API retrieves backing cost data broken down by individual assets in your cluster but also provides various aggregations of this data. This version of the Assets API should only be consulted for users who have configured Kubecost Aggregator

Path Parameters

NameTypeDescription

window*

string

Dictates the applicable window for measuring historical asset cost.

aggregate

string

Used to consolidate cost model data. Supported values are account, cluster, project, providerid, provider, and type. Passing an empty value for this parameter or none at all returns data by an individual asset. Supports multi-aggregation (aggregation of multiple categories) in a comma separated list, such as aggregate=account,project.

accumulate

boolean

When set to false, this endpoint returns daily time series data vs cumulative data. Default value is false.

disableAdjustments

boolean

When set to true, zeros out all adjustments from cloud provider reconciliation, which would otherwise change the totalCost. Default value is false.

format

string

When set to csv, will download an accumulated version of the asset results in CSV format. By default, results will be in JSON format.

offset

int

Refers to the number of pages you are searching through which will increase by integers for the amount of pages you want to skip. Starting value is 0, representing the first page of results.

limit

int

Refers to the number of line items per page. Pair with the offset parameter to filter your payload to specific sections of line items. You should also set accumulate=true to obtain a single list of line items, otherwise you will receive a group of line items per interval of time being sampled. Paginates by all five item types, and will provide lists for all five types.

filter

string

Filter your results by any category which you can aggregate by, can support multiple filterable items in the same category in a comma-separated list. For example, to filter results by clusters A and B, use filter=cluster:clusterA,clusterB See our Filter Parameters doc for a complete explanation of how to use filters and what categories are supported.

  {
    cluster: "..."  // parent cluster for asset
    cpuCores: 1  // number of CPUs, given this is a node asset type
    cpuCost: 0.00 // cumulative cost of CPU measured over time window
    discount: 0.0 // discount applied to asset cost
    end: "2020-08-21T00:00:00+0000" // end of measured time window
    gpuCost: 0
    key: "..."
    name: "..."
    nodeType: "..."
    preemptible: 0
    providerID: "..."
    ramBytes: 0
    ramCost: 0.00
    start: "2020-08-20T00:00:00+0000"
    adjustment: 0.00 // amount added to totalCost during reconciliation with cloud provider data
    totalCost: 0.00 // total asset cost after applied discount
    type: "node" // e.g. node, disk, cluster management fee, etc
}

Using window parameter:

Acceptable formats for using window parameter include:

  • "15m", "24h", "7d", "48h", etc.

  • "today", "yesterday", "week", "month", "lastweek", "lastmonth"

  • "1586822400,1586908800", etc. (start and end unix timestamps)

  • "2020-04-01T00:00:00Z,2020-04-03T00:00:00Z", etc. (start and end UTC RFC3339 pairs)

API examples

Retrieve assets cost data for the past week, aggregated by type, and as cumulative object data:

http://localhost:9090/model/assets?window=1w&aggregate=type&accumulate=true

Retrieve all GCP costs, aggregated by asset type, in the past five days:

http://localhost:9090/model/assets?window=5d&aggregate=type&filterProviders=GCP

Querying with /topline endpoint to view cost totals across query (Aggregator only)

/topline is an optional API endpoint which can be added to your Assets query via .../model/assets/topline?window=... to provide a condensed overview of your total cost metrics including all line items sampled. You will receive a single list which sums the values per all items queried (totalCost), where numResults displays the total number of items sampled.

    "code": 200,
    "data": {
        "totalCost": ,
        "adjustment": ,
        "numResults": 
    }
}

Enable CPU and RAM cost breakdown

As of v1.106, Prometheus queries for CPU and RAM mode breakdown are disabled by default. To receive these metrics, you must manually enable them by setting the Helm flag:

.Values.kubecostModel.assetModeBreakdownEnabled = true

This will enable fields ramBreakdown, cpuBreakdown, and breakdown in the output of all future Assets queries.

Last updated