Home / OCI

OCICheat sheetBeginner

OCI cost and usage cheat sheet - answering \"what did we spend and where\" with the Usage API and cost reports

Quick CLI and console recipes to break OCI spend down by service, compartment and tag, find daily spikes, and pull the detailed cost reports for your own analysis.

Deepak Bhardwaj4 min read

Applies toOCI Cost Analysis, Usage API and cost/usage reports; OCI CLI 3.x; users with read access to usage reports

Permissions

Reading cost data needs a tenancy-level policy such as:

Allow group FinOps to read usage-report in tenancy
Allow group FinOps to read usage-budgets in tenancy

Cost reports are read through a special cross-tenancy policy (endorse/define). Copy it exactly from the OCI documentation page "Accessing Cost and Usage Reports".

Usage API from the CLI

Use the tenancy OCID as --tenant-id. Times are UTC and must align to the granularity: midnight for DAILY, the first of the month for MONTHLY.

Cost per service, last month:

oci usage-api usage-summary request-summarized-usages \
  --tenant-id $TENANCY \
  --time-usage-started 2026-09-01T00:00:00Z --time-usage-ended 2026-10-01T00:00:00Z \
  --granularity MONTHLY --query-type COST \
  --group-by '["service"]' \
  --query "sort_by(data.items,&\"computed-amount\")[-10:].{service:service,cost:\"computed-amount\",cur:currency}" -o table

Daily cost for a spike hunt:

oci usage-api usage-summary request-summarized-usages --tenant-id $TENANCY \
  --time-usage-started 2026-10-01T00:00:00Z --time-usage-ended 2026-10-26T00:00:00Z \
  --granularity DAILY --query-type COST --group-by '["service"]' \
  --query "data.items[].{day:\"time-usage-started\",service:service,cost:\"computed-amount\"}" -o table

By compartment:

oci usage-api usage-summary request-summarized-usages --tenant-id $TENANCY \
  --time-usage-started 2026-10-01T00:00:00Z --time-usage-ended 2026-10-26T00:00:00Z \
  --granularity MONTHLY --query-type COST \
  --group-by '["compartmentPath"]' --compartment-depth 3

By cost-tracking tag (the tag must be a defined tag marked as a cost-tracking tag):

oci usage-api usage-summary request-summarized-usages --tenant-id $TENANCY \
  --time-usage-started 2026-10-01T00:00:00Z --time-usage-ended 2026-10-26T00:00:00Z \
  --granularity MONTHLY --query-type COST \
  --group-by-tag '[{"namespace":"Finance","key":"CostCenter"}]'

Usage quantity rather than cost (for example OCPU hours):

... --query-type USAGE --group-by '["service","skuName","unit"]'

Useful --group-by values include service, skuName, compartmentName, compartmentPath, region, resourceId and tagNamespace/tagKey/tagValue. Check --help for the full list in your CLI version.

Tip

Grouping by resourceId for a whole month returns a lot of rows. Filter to one service first with --filter (JSON), or use the cost reports below.

Find the expensive resources

oci usage-api usage-summary request-summarized-usages --tenant-id $TENANCY \
  --time-usage-started 2026-10-01T00:00:00Z --time-usage-ended 2026-10-26T00:00:00Z \
  --granularity MONTHLY --query-type COST --group-by '["resourceId","service"]' \
  --filter '{"operator":"AND","dimensions":[{"key":"service","value":"COMPUTE"}]}' \
  --query "sort_by(data.items,&\"computed-amount\")[-15:].{res:\"resource-id\",cost:\"computed-amount\"}" -o table

Service names in filters must match the names returned by an unfiltered query. Run one first to see the exact spelling.

Detailed cost reports (CSV)

OCI writes detailed cost and usage reports as gzipped CSV files to an Oracle-owned bucket you can read:

oci os object list --namespace-name bling --bucket-name $TENANCY \
  --prefix reports/cost-csv/ --all --query "data[-5:].name" -o table

oci os object get --namespace-name bling --bucket-name $TENANCY \
  --name reports/cost-csv/<file>.csv.gz --file cost.csv.gz

Load them into a database, a spreadsheet, or Autonomous Database for trend analysis. The columns include the resource ID, compartment, tags, SKU, quantity and cost.

Console shortcuts

Question Where
Spend this month vs last Billing & Cost Management > Cost Analysis, "Last 6 months", monthly
What drove a spike Cost Analysis, daily granularity, group by service then by resource
Spend per team Cost Analysis, group by compartment or cost-tracking tag
Forecast Cost Analysis with forecast enabled
Alert before overspend Budgets on a compartment or tag, with alert rules at 80% and 100%

Budgets from the CLI

oci budgets budget create --compartment-id $TENANCY \
  --amount 5000 --reset-period MONTHLY --target-type COMPARTMENT \
  --targets '["'$APP_COMPARTMENT'"]' --display-name app-monthly

oci budgets alert-rule create --budget-id <budget-ocid> --type FORECAST \
  --threshold 90 --threshold-type PERCENTAGE --recipients "finops@example.com"

Common reasons for a jump

Pattern Likely cause
Compute up, steady New or resized instances; check for non-production left running
Block volume up Higher VPUs, or orphaned volumes and backups
Object Storage up Logs/backups without lifecycle rules
Network up Egress to the internet or between regions
Database up Auto-scaling ECPUs, or a larger Exadata/DB system shape

Checklist

  • Read policy for the FinOps group
  • Monthly cost by service and compartment reviewed
  • Cost-tracking tags defined and applied
  • Budgets with forecast alerts per compartment
  • Cost reports exported for trend analysis