AWS Cost Explorer icon

AWS Cost Explorer

Retrieve cost, usage, anomalies and recommendations from AWS Cost Explorer

Actions12

Cost and Usage → Get

AI-generated

Summary

Retrieve AWS cost and usage metrics for a date range, with optional grouping and filters. Return nested time-period results or flattened rows for downstream reporting.

Inputs

  • startDate (required) — Required start date in YYYY-MM-DD format.
  • endDate (required) — Required exclusive end date in YYYY-MM-DD format.
  • granularity — Time interval: DAILY, HOURLY, or MONTHLY. Defaults to MONTHLY.
  • metrics — Select AmortizedCost, BlendedCost, NetAmortizedCost, NetUnblendedCost, NormalizedUsageAmount, UnblendedCost, or UsageQuantity. Defaults to UnblendedCost.
  • groupBy — Optional primary grouping by instance type, linked account, purchase type, region, service, tag, or usage type. Defaults to none.
  • groupByTagKey — Required when grouping by TAG; specifies the tag key.
  • groupBySecondary — Optional second grouping by instance type, linked account, purchase type, region, or service. Shown when primary grouping is enabled; defaults to none.
  • serviceFilter — Optional comma-separated AWS service names. Whitespace is trimmed and empty entries are ignored.
  • linkedAccountFilter — Optional comma-separated linked account IDs.
  • regionFilter — Optional comma-separated AWS regions.
  • tagFilter — Optional tag key and comma-separated tag values. Applied only when both key and value are supplied; combined with other filters using AND.
  • excludeCredits — Exclude records of type Credit, Refund, and Discount. Defaults to false.
  • formatOutput — Flatten results into rows with numeric metric amounts and units. Defaults to false.

Output shape

One item containing ResultsByTime per input item, or multiple flattened row items when formatOutput is enabled.

Automatically fetches all pages and concatenates their time-period results. Default output preserves nested AWS period data but omits other response fields. Flattened output contains start, end, estimated, optional group keys, and _amount and _unit fields for available metrics; each group becomes a row, or an ungrouped period becomes one row. With continue-on-fail enabled, a failed input produces an item containing error.

Links

Discussion