Requirements
Install the CostGraph CLI and connect a source of cost data to your tenant. A connection with no imported data can return an empty result. For grouped queries, use a saved browser session or an API key withfocus:read. Refer to API keys to create a key. The overview and provider-summary commands require a browser session in the current release.
Group spend by provider
The following command prints month-to-date spend grouped by provider.Browse results interactively
Remove--no-interactive to open the cost browser in a terminal.
Compare services within a provider
Put dimensions in the order you want to explore them. The following command groups AWS spend by provider and then service.aws argument selects a value of the first dimension, which is provider in this example. It is equivalent to adding --filter provider:aws.
You can also use --provider aws to filter by provider without changing your grouping.
Filter a query
Use--filter with a dimension and value. The following query groups AWS and Google Cloud spend by service.
--sub-accounts to break groups down by sub-account. A source must report sub-account attribution before that breakdown contains useful data.
Choose a period
The default period ismonth_to_date. Use --period to select a different window.
Calendar month
The following command compares providers during October 2026.Custom dates
For a custom window, pass its start and end.Choose billed or allocated costs
Grouped queries use thebilled layer by default. To query the allocation layer, add --layer allocation.
Sort and limit results
Sort the top-level rows by current spend and show ten results.--sort=-current for ascending order. Other sort fields include previous, change, share, usage, and name.
--limit limits the rows printed by the CLI. --group-limit limits groups at each query level and combines the remaining groups into other. Do not treat these options as interchangeable.
Return JSON for a script
Add-o json to skip the browser and return structured data.
totals, groups, and series. Each member of groups has a key and cost measures such as current and previous.
The following command extracts provider names and current spend. It requires jq.
Read the cost overview
With a saved browser session, the following command prints total spend, comparison with the preceding period, and provider totals.costgraph cost without a subcommand uses month-to-date spend. costgraph cost overview offers the same overview and can prompt for a period in an interactive terminal.
Provider totals
Print providers ranked by spend with a saved browser session.costgraph cost get --group-by provider.
Check an empty result or access error
Confirm the selected tenant, period, filters, and layer. A successful query can return no groups when the source has no data in that window. If CostGraph rejects the credential, check Resolve permission errors. A saved browser session takes precedence over an API key set in the environment.Command reference
Commands are shown without thecostgraph prefix. Add --help for the complete flag list.
Cost query commands
Run each command with thecostgraph prefix. costs is an alias for cost.
Shows spend, period comparison, and provider totals. Requires a session. Bare
cost uses month-to-date without prompting.Dimensions and filters
Pass these flags tocostgraph cost get.
Filters
dimension:value. Repeat a dimension for OR. Different dimensions narrow results together.