Skip to main content
Use the CLI to compare spend across providers and services, narrow a query to one workload, or read costs in a script. Queries use the tenant attached to your credential.

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 with focus: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.
Each row identifies a provider and its current spend, comparison with the preceding period, and share of the result. These are your tenant’s costs, not a price estimate for new infrastructure.

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.
The 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.
Repeated values for the same dimension use OR. Filters on different dimensions narrow the query together. Use the provider identifiers present in your data. Add --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 is month_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 the billed layer by default. To query the allocation layer, add --layer allocation.
Billed and allocated costs answer different questions. Compare results from the same layer and period. An allocation query needs the relevant allocation data in your tenant.

Sort and limit results

Sort the top-level rows by current spend and show ten results.
Use --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.
The result includes 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.
Check the command’s exit status before using its output in automation. Refer to Configuration and output for credential selection and output settings.

Read the cost overview

With a saved browser session, the following command prints total spend, comparison with the preceding period, and provider totals.
Running 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.
These two summary commands do not accept an API key in the current release. For an API-key workflow, use 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 the costgraph prefix. Add --help for the complete flag list.

Cost query commands

Run each command with the costgraph prefix. costs is an alias for cost.
command
Queries grouped spend. Accepts a session or a key with focus:read.
command
Shows spend, period comparison, and provider totals. Requires a session. Bare cost uses month-to-date without prompting.
command
Ranks providers by spend. Requires a session. Alias cost provider.

Dimensions and filters

Pass these flags to costgraph cost get.
string[]
Sets dimension order. Separate dimensions with commas, such as provider,service.
string[]
Filters dimension:value. Repeat a dimension for OR. Different dimensions narrow results together.
string
Filters the provider without changing grouping.
boolean
Breaks groups down by sub-account when attribution data exists.
string
default:"billed"
Chooses billed or allocation costs.

Periods and dates

These flags control spend query windows.
string
default:"month_to_date"
Selects month_to_date, last_7d, last_30d, calendar_month, or custom.
string
Sets the calendar month as YYYY-MM.
string
Set custom date or RFC 3339 timestamp boundaries.

Result order and output

Use these flags to control the returned rows.
string
Sorts by current, previous, change, share, usage, or name. Prefix with - for ascending order.
integer
Limits rows printed by the CLI.
integer
Limits groups at each query level and combines remaining groups into other.
boolean
Prints a static result instead of opening the cost browser.
string
Use json for structured totals, groups, and series.