fbpx
GEThttps://api.spotinst.io/mcs/kubernetes/cluster/{clusterIdentifier}/costs?fromDate={timeDate}&toDate={timeDate}&aggregationPeriod=daily&accountId={ACCOUNT_ID}

Describes Kubernetes cluster costs in a time range based on resource allocation.

The response will provide the costs distribution per cluster, namespace, and deployment

URL Parameters

Parameter Type Description
toDate * String

data values following either a date format (yyyy-mm-dd ; 2016-11-20) or Unix Timestamp (1494751821472)

fromDate * String

data values following either a date format (yyyy-mm-dd ; 2016-11-20) or Unix Timestamp (1494751821472)

aggregationPeriod String

Possible values: "daily", null. For daily value response contains aggregated data by day. If null - response returns sum of costs per period

ACCOUNT_ID String

Your Spotinst accountId associated with your token

Example: act-123abc
Request

Headers
{
    "Content-Type": "application/json",
    "Authorization": "Bearer ${token}"
}
Response - 200

Headers
{
    "Content-Type": "application/json"
}
Body
Copied!
Downloaded!
{
    "request": {
        "id": "9768cc69-8c7b-4245-bdb1-18f8097029d0",
        "url": "/mcs/kubernetes/cluster/mycluster/costs?fromDate=2018-06-20&toDate=2018-07-20",
        "method": "GET",
        "timestamp": "2018-07-20T07:48:46.593Z"
    },
    "response": {
        "status": {
            "code": 200,
            "message": "OK"
        },
        "kind": "spotinst:mcs:kubernetes:cluster:costs",
        "items": [
            {
                "totalCost": 115.97803,
                "namespaces": [
                    {
                        "namespace": "prd354",
                        "cost": 64.812904
                    },
                    {
                        "namespace": "prd1811",
                        "cost": 0.912011
                    },
                    {
                        "namespace": "t-system",
                        "cost": 7.864456
                    },
                    {
                        "namespace": "h-contour",
                        "cost": 1.3037746
                    },
                    {
                        "namespace": "prd1683",
                        "cost": 2.154953
                    },
                    {
                        "namespace": "kube-system",
                        "cost": 15.617937
                    },
                    {
                        "namespace": "prd122",
                        "cost": 2.5223486
                    },
                    {
                        "namespace": "prd396",
                        "cost": 0.68626857
                    },
                    {
                        "namespace": "prd121",
                        "cost": 0.9387672
                    },
                    {
                        "namespace": "ko",
                        "cost": 0.934621
                    }
                ],
                "deployments": [],
                "standAlonePodsCost": 0,
                "headroomCost": 18.23413
            }
        ],
        "count": 1
    }
}
Request - Get showback costs with daily aggregation

Headers
{
    "Content-Type": "application/json",
    "Authorization": "Bearer ${token}"
}
Response

Body
Copied!
Downloaded!
{
    "request": {
        "id": "9768cc69-8c7b-4245-bdb1-18f8097029d0",
        "url": "/mcs/kubernetes/cluster/mycluster/costs?fromDate=2018-06-20&toDate=2018-07-20&aggregationPeriod=daily",
        "method": "GET",
        "timestamp": "2018-07-20T07:48:46.593Z"
    },
    "response": {
        "status": {
            "code": 200,
            "message": "OK"
        },
        "kind": "spotinst:mcs:kubernetes:cluster:costs",
        "items": [
		{
			"totalCost": 1.2099,
			"namespaces": [
				{ "namespace": "default", "cost": 0.69470173 } { "namespace": "kube-system", "cost": 0.41793224 }
			],
			"deployments": [
				{ "deploymentName": "efs-provisioner", "namespace": "default", "cost": 0.69470173 },
				{ "deploymentName": "kube-dns-autoscaler", "namespace": "kube-system", "cost": 0.41793224 }
			],
			"headroomCost": 0,
			"idleCost": 1.2099,
			"timestamp": "2019-03-31T00:00:00.000Z"
		},
		{
			"totalCost": 4.8536,
			"namespaces": [
				{ "namespace": "default", "cost": 3.653509 },
				{ "namespace": "kube-system", "cost": 0.76842964 }
			],
			"deployments": [
				{ "deploymentName": "second-deployment", "namespace": "default", "cost": 3.653509 },
				{ "deploymentName": "standAlone", "namespace": "kube-system", "cost": 0.76842964 }
			],
			"headroomCost": 0.013240553,
			"idleCost": 4.840359,
			"timestamp": "2019-03-26T00:00:00.000Z"
		}
	],
	"count": 2
	}
}