Skip to content

cost

The cost command lets you view and analyze cloud infrastructure costs directly from provider APIs. It fetches real cost data using your configured cloud credentials and supports multiple providers including AWS, GCP, Azure, and Cloudflare.

When invoked without a subcommand, cost defaults to showing a cost summary.

Usage

bash
clanker cost [subcommand] [flags]

Persistent Flags

These flags apply to all cost subcommands.

FlagTypeDefaultDescription
--providerstringallFilter by cloud provider. Options: aws, gcp, azure, cloudflare, all
--startstringFirst of current monthStart date in YYYY-MM-DD format
--endstringTodayEnd date in YYYY-MM-DD format
--formatstringtableOutput format. Options: table, json
--topint10Maximum number of results to display
--profilestringFrom AWS_PROFILE envAWS CLI profile to use for cost data retrieval

Provider Support

ProviderAPI UsedStatus
AWSCost Explorer APIAvailable
GCPCloud Billing APIComing soon
AzureCost Management APIComing soon
CloudflareAnalytics APIComing soon

Subcommands

cost summary

Display a summary of costs across all configured cloud providers. Shows total cost, per-provider breakdown, top services, and forecast data.

bash
clanker cost summary [flags]

Examples:

bash
# Show cost summary for all providers
clanker cost summary

# Show only AWS costs
clanker cost summary --provider aws

# Show costs for a specific date range
clanker cost summary --start 2025-01-01 --end 2025-01-31

# Output as JSON
clanker cost summary --format json

# Use a specific AWS profile
clanker cost summary --provider aws --profile production

cost detail

Display a detailed cost breakdown by service. When a specific provider is selected, the output includes a full per-service itemization. When set to all, it shows top services across all providers.

bash
clanker cost detail [flags]

Examples:

bash
# Show detailed breakdown for all providers
clanker cost detail

# Show AWS service-by-service breakdown
clanker cost detail --provider aws

# Show top 20 services in JSON format
clanker cost detail --top 20 --format json

# Detailed costs for a specific date range
clanker cost detail --provider aws --start 2025-02-01 --end 2025-02-28

cost trend

Display daily cost trends over a specified time period. This is useful for spotting spending patterns, spikes, or gradual increases over time.

bash
clanker cost trend [flags]

Examples:

bash
# Show cost trend for the current month
clanker cost trend

# Show cost trend for January 2025
clanker cost trend --start 2025-01-01 --end 2025-01-31

# Output trend data as JSON for further processing
clanker cost trend --format json

# Trend for AWS only
clanker cost trend --provider aws

cost forecast

Display cost forecasts for the remainder of the current month and the next month. Forecasts are generated by the cloud provider based on historical spending data.

bash
clanker cost forecast [flags]

TIP

AWS Cost Explorer forecast requires sufficient historical data to generate predictions. If your account is new or has limited usage history, forecast data may not be available.

Examples:

bash
# Show cost forecast
clanker cost forecast

# Show forecast in JSON format
clanker cost forecast --format json

# Forecast for AWS only
clanker cost forecast --provider aws

cost anomalies

Display detected cost anomalies and potential waste. This subcommand highlights unusual spending patterns that may warrant investigation.

bash
clanker cost anomalies [flags]

Examples:

bash
# Show detected anomalies
clanker cost anomalies

# Show anomalies in JSON format
clanker cost anomalies --format json

# Show anomalies for AWS only
clanker cost anomalies --provider aws

cost tags

Display costs grouped by resource tags. This is particularly useful for organizations that use tagging strategies to allocate costs by team, environment, project, or other dimensions.

bash
clanker cost tags [flags]

Additional Flags

FlagTypeDefaultDescription
--keystringEnvironmentTag key to group costs by

Examples:

bash
# Show costs grouped by the default "Environment" tag
clanker cost tags

# Show costs grouped by team
clanker cost tags --key Team

# Show costs grouped by project, output as JSON
clanker cost tags --key Project --format json

# Costs by tag for a specific date range
clanker cost tags --key Environment --start 2025-01-01 --end 2025-03-31

cost export

Export cost data to a file. The format is automatically inferred from the file extension when --format is not explicitly set: .json files export as JSON, and all other extensions default to CSV.

bash
clanker cost export [flags]

Additional Flags

FlagTypeDefaultDescription
--outputstring(required)Output file path
--group-bystringproviderGrouping strategy. Options: provider, service, tag

Examples:

bash
# Export all costs to a CSV file
clanker cost export --output costs.csv

# Export as JSON
clanker cost export --output costs.json --format json

# Export AWS-only costs
clanker cost export --output aws-costs.csv --provider aws

# Export costs for a specific period, grouped by service
clanker cost export --output q1-costs.csv --start 2025-01-01 --end 2025-03-31 --group-by service

cost llm

Display LLM usage and cost information. Full LLM cost tracking requires the clanker-cloud backend to record per-request usage data. For AWS Bedrock model invocation costs, use clanker cost detail --provider aws instead, as those costs appear on your AWS bill.

bash
clanker cost llm [flags]

Examples:

bash
# Show LLM usage and cost info
clanker cost llm

# Output as JSON
clanker cost llm --format json

INFO

Bedrock costs appear on your AWS bill under service names such as "Claude Opus 4.5 (Amazon Bedrock Edition)" and "Claude Haiku 4.5 (Amazon Bedrock Edition)".


Authentication

The cost command uses your existing cloud provider credentials. For AWS, it relies on the AWS CLI profile configured in your clanker config or specified via the --profile flag. If neither is set, it falls back to the AWS_PROFILE environment variable.

Make sure your AWS credentials have permissions for the Cost Explorer API (ce:GetCostAndUsage, ce:GetCostForecast).

See Also

  • Configuration -- Setting up cloud provider credentials
  • profiles -- Listing available AWS profiles
  • ask -- Querying infrastructure with natural language