Search…
⌃K
Links

Assets API

get
http://<your-kubecost-address>/model
/assets
Assets API

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)

Using filter parameters:

  • Optional filter parameters take the format of &<filter>=<value>.
  • Some filters require cloud configuration, which can be set at <your-kubecost-address>/keyinstructions.html
  • Multiple filter selections evaluate as ANDs. Each filter selection accepts comma-separated values that evaluate as ORs.
    • For example, including both filterClusters=cluster-one and filterNames=name1,name2 logically evaluates as (cluster == cluster-one) && (name == name1 || name == name2)
  • All filters are case-sensitive except for filterTypes
  • All filters accept wildcard filters denoted by a URL-encoded * suffix, except for filterTypes and the label key in filterLabels
    • For example, filterProviderIDs=gke%2A will return all assets with a gke string prefix in its Provider ID.
    • For example, filterLabels=deployment%3Dkube%2A will return all assets with deployment label value containing a kube prefix.
  • Invalid filters return no assets.

API example

Retrieve assets cost data for the past seven days, aggregated by type, and as cumulative object data:
Request
Response
http://localhost:9090/model/assets?window=7d&aggregate=type&accumulate=true
{
"code": 200,
"data": [
{
"Cloud": {
"type": "Cloud",
"properties": {
"provider": "GCP",
"account": "01AC9F-74CF1D-5565A2"
},
"labels": {},
"window": {
"start": "2023-01-03T00:00:00Z",
"end": "2023-01-10T00:00:00Z"
},
"start": "2023-01-03T00:00:00Z",
"end": "2023-01-09T05:00:00Z",
"minutes": 8940.000000,
"adjustment": 0.000000,
"credit": -37.799792,
"totalCost": 2494.201159
},
"ClusterManagement": {
"type": "ClusterManagement",
"properties": {
"category": "Management",
"provider": "GCP",
"project": "guestbook-227502",
"service": "Kubernetes",
"cluster": "cluster-one"
},
"labels": {
"firebase": "enabled",
"namespace": "kubecost",
"test_gcp_label": "test_gcp_value"
},
"window": {
"start": "2023-01-03T00:00:00Z",
"end": "2023-01-10T00:00:00Z"
},
"start": "2023-01-03T00:00:00Z",
"end": "2023-01-10T00:00:00Z",
"minutes": 10080.000000,
"totalCost": 16.296993
},
"Disk": {
"type": "Disk",
"properties": {
"category": "Storage",
"provider": "GCP",
"project": "guestbook-227502",
"service": "Kubernetes",
"cluster": "cluster-one"
},
"labels": {
"firebase": "enabled",
"namespace": "kubecost",
"test_gcp_label": "test_gcp_value"
},
"window": {
"start": "2023-01-03T00:00:00Z",
"end": "2023-01-10T00:00:00Z"
},
"start": "2023-01-03T00:00:00Z",
"end": "2023-01-09T19:06:00Z",
"minutes": 9786.000000,
"byteHours": 48176821506867.203125,
"bytes": 295382106112.000000,
"byteHoursUsed": 701875686596.947632,
"byteUsageMax": null,
"breakdown": {
"idle": 0.9379000878645455,
"other": 0,
"system": 0.0620999121354546,
"user": 0
},
"adjustment": 0.000000,
"totalCost": 2.494985,
"storageClass": "",
"volumeName": "",
"claimName": "",
"claimNamespace": ""
},
"LoadBalancer": {
"type": "LoadBalancer",
"properties": {
"category": "Network",
"provider": "GCP",
"project": "guestbook-227502",
"service": "Kubernetes",
"cluster": "cluster-one"
},
"labels": {
"firebase": "enabled",
"namespace": "kubecost",
"test_gcp_label": "test_gcp_value"
},
"window": {
"start": "2023-01-03T00:00:00Z",
"end": "2023-01-10T00:00:00Z"
},
"start": "2023-01-03T00:00:00Z",
"end": "2023-01-09T19:06:00Z",
"minutes": 9786.000000,
"adjustment": 0.000000,
"totalCost": 8.155000
},
"Node": {
"type": "Node",
"properties": {
"category": "Compute",
"provider": "GCP",
"project": "guestbook-227502",
"service": "Kubernetes",
"cluster": "cluster-one"
},
"labels": {
"firebase": "enabled",
"instance": "10.95.11.109:9003",
"job": "kubecost",
"label_app": "integration",
"label_beta_kubernetes_io_arch": "amd64",
"label_beta_kubernetes_io_os": "linux",
"label_cloud_google_com_gke_boot_disk": "pd-standard",
"label_cloud_google_com_gke_container_runtime": "docker",
"label_cloud_google_com_gke_os_distribution": "cos",
"label_department": "engineering",
"label_env": "test",
"label_failure_domain_beta_kubernetes_io_region": "us-central1",
"label_failure_domain_beta_kubernetes_io_zone": "us-central1-a",
"label_kubernetes_io_arch": "amd64",
"label_kubernetes_io_os": "linux",
"label_owner": "kubecost",
"label_product": "integration",
"label_team": "kubecost",
"label_topology_kubernetes_io_region": "us-central1",
"label_topology_kubernetes_io_zone": "us-central1-a",
"namespace": "kubecost",
"test_gcp_label": "test_gcp_value"
},
"window": {
"start": "2023-01-03T00:00:00Z",
"end": "2023-01-10T00:00:00Z"
},
"start": "2023-01-03T00:00:00Z",
"end": "2023-01-09T19:06:00Z",
"minutes": 9786.000000,
"nodeType": "",
"cpuCores": 6.000000,
"ramBytes": 23881949184.000000,
"cpuCoreHours": 978.600000,
"ramByteHours": 3895145911910.399902,
"GPUHours": 0.000000,
"cpuBreakdown": {
"idle": 0.8786219902310968,
"other": 0.0013172388726963124,
"system": 0.016174278350509344,
"user": 0.1038864925456978
},
"ramBreakdown": {
"idle": 0.9551354180444207,
"other": 0,
"system": 0.011233367196352187,
"user": 0.03363121475922688
},
"preemptible": 0.000000,
"discount": 0.198803,
"cpuCost": 30.939847,
"gpuCost": 0.000000,
"gpuCount": 0.000000,
"ramCost": 15.355342,
"adjustment": 0.000000,
"totalCost": 37.091556
}
}
]
}