After deploying the RealTheory collector to a Kubernetes cluster (See Installing RealTheory in a Cluster), the cluster and its associated objects become available in the RealTheory API within minutes.
Get Daily Cost Report
To get the Daily Cost report data for all deployments for a given cluster, call the method below on the K8sReports endpoint.
GET <endpoint>/theory/api/v1/k8sreports/dailycostreport/deployments/search/query/{query}/{offset}/{span}?index={index}&count={count}&order={order}&direction={direction}
where
{endpoint}- is the URL of the RealTheory SaaS portal for your account.{query}- is a query used to limit the results to deployments for a given cluster.{offset}- is an offset from the current time, in a human readable format, that represents the start of the report data. Supported examples include '24h', '7d', '31d', '365d'{span}- a span of time, in a human readable format, to include in the report data. Supported examples include '24h', '7d', '31d', '365d'{index}- is the starting index of the rows to include in the list. This parameter is optional and defaults to 0 if not specified.{count}- is maximum number of rows to return. This parameter is optional and defaults to 100 if not specified.{order}- is a string containing the name of the attribute to sort on. This parameter is optional. Default value is totalCost.{direction}- is a number that controls the direction of the sort. A value equal to or greater than 0 indicates ascending order; a value less than 0 indicates descending order. This parameter is optional and defaults to -1 if not specified.
Note: All calls to RealTheory APIs must be authenticated and authorized. See Authentication for more details.
Example
GET myendpoint.realtheory.io/theory/api/v1/k8sreports/dailycostreport/deployments/search/query/metadata.name=my-deployment/31d/31d?index=0&count=50&order=totalCost&direction=-1
which returns the first 50 rows for the Daily Cost report for the last 31 days, listing only the deployments named my-deployment, sorted by deployments with the highest total cost to the lowest total cost.
Output
Returns an array of DeploymentItem objects.
[
{
"id": "59f005f9-8e36-4e4e-a346-c140c6341838",
"metadata": {
"id": "59f005f9-8e36-4e4e-a346-c140c6341838",
"name": "my-deployment",
"clusterId": "8ca6aa4c-8c7d-9fb9-c751-3e038f90d283",
"clusterName": "realtheory-cluster-01",
"customResourceDefinitionId": "00000000-0000-0000-0000-000000000000",
"customResourceDefinitionName": "",
"namespaceId": "d61ccb51-0c9e-40b7-9730-4db1223ab3c6",
"namespaceName": "realtheory-example",
"customResourceId": "00000000-0000-0000-0000-000000000000",
"customResourceName": "",
"timestamp": "2024-03-08T00:30:27.1391919Z"
},
"totalCost": 9.97616063,
"costs": [
{
"total": 0.33017443,
"cpuUtilization": 3.0416667,
"memoryUtilization": 77.93017,
"utilization": 40.485832,
"efficiency": 12.0275,
"timestamp": "2024-02-06T00:00:00Z"
},
{
"total": 0.31641716,
"cpuUtilization": 3.0434783,
"memoryUtilization": 81.07564,
"utilization": 42.06,
"efficiency": 12.406957,
"timestamp": "2024-02-07T00:00:00Z"
},
{
"total": 0.31643172,
"cpuUtilization": 3.0289855,
"memoryUtilization": 81.49785,
"utilization": 42.263042,
"efficiency": 12.444782,
"timestamp": "2024-02-08T00:00:00Z"
},
...
],
"clusterName": "realtheory-cluster-01",
"namespaceName": "realtheory-example",
"deploymentName": "my-deployment",
"accountName": "RealTheory,Inc.",
"accountOwner": "Joe.Bloggs"
},
...
]
Note: Content has been omitted from the JSON response above for brevity.