Thank you for supporting the Cloud Customer Connect Community in 2024. It's a gift to work with you!

Look back
You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

oci cli to display summarized usage and cost

I have been playing around with oci usage-api usage-summary request-summarized-usagescommand 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,

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!