oci cli to display summarized usage and cost
I have been playing around with oci usage-api usage-summary request-summarized-usages
command for quite some time to get a report of total usage of each service, unit, cost between a period of time.
What I have tried so far is, created a file named ociinput.json with below contents,
{
"compartmentId": "ocid1.tenancy.oc1..xxxxxxx",
"timeUsageStarted": "2024-12-01T00:00:00+00:00",
"timeUsageEnded": "2024-12-31T00:00:00+00:00",
"granularity": "MONTHLY",
"queryType": "COST",
"resourceType": "VM",
"region": "ap-hyderabad-1",
"groupBy": ["service"],
"tenantId": "ocid1.tenancy.oc1..xxxxx"
}
And ran command as, oci usage-api usage-summary request-summarized-usages --from-json file://ociinput.json --query 'data.items[]["service", "attributed-usage", "unit", "attributed-cost", "currency", "time-usage-started", "time-usage-ended"]'
The result was as below,