Use Athena scan limits to stop oversized AI cost-report queries: put the reports in a dedicated workgroup and configure a per-query data scanned limit. Then verify that each report actually ran in that workgroup. Add an aggregate usage alert for repeated scans, with an owner who can pause the reporting schedule. A workgroup alert alone does not stop queries.

This guide is for platform engineers and FinOps owners querying AI billing exports or usage ledgers in Amazon S3 with on-demand Athena SQL. It controls the expense of producing the report. Keep model inference, storage, and reporting costs visible as separate expenses. Athena SQL with capacity reservations and Athena Spark use compute-based pricing that needs a different calculation.

Last reviewed: November 19, 2026 (Asia/Shanghai and UTC).

Give scheduled cost reports their own workgroup

AWS’s workgroup guide explicitly recommends separating scheduled applications from ad hoc analyst queries. Use a workgroup such as ai-cost-reporting for the automated dashboard. Keep exploratory queries in another approved workgroup so their traffic does not obscure the reporting workload’s scan history.

Record the AWS account, Region, workgroup, reporting role, schedule, query revision, input snapshot, and owner. Set the workgroup explicitly in every submission path, including the scheduler and any JDBC or ODBC configuration. Selecting it in one console tab does not configure a separate application.

Workgroups are IAM resources. Review the reporting role’s permissions so its automated path uses the approved workgroup, and keep permission to change limits with the appropriate administrator. Where the policy requires a mandatory control, also check whether the role can submit through another workgroup, including primary. A restriction on one workgroup cannot govern queries submitted elsewhere.

Configure the results destination and access policy before moving the schedule. AWS supports enforcing workgroup settings for result location and encryption; coordinate that change with any automation that reads the output. Those settings govern output handling. The scan cutoff is the separate control described below.

Pair query cancellation with an aggregate alert

The Athena data usage controls reference documents two independent mechanisms:

ControlWhat it measuresDocumented action
Per-query data scanned limitData scanned by each query in the workgroupCancels a query that exceeds the limit
Workgroup data usage alertAggregate scanned data over the configured periodSends the configured notification; does not automatically cancel queries

There is one per-query limit per workgroup, applying to each query that runs there. AWS allows multiple aggregate alert thresholds. This lets a team use an early warning and an escalation threshold without confusing either with query admission.

In the Athena console, open Workgroups, select the reporting workgroup, and use Execution controls → Edit controls to set Data scanned limit. Choose a value from the measured scan size of legitimate report executions and the maximum exposure the owner accepts. AWS currently documents a minimum of 10 MB. Do not copy a sample threshold into a production workload without measuring it.

Next, edit the workgroup and add a Workgroup data usage alert with a data threshold, time period, and SNS topic. Verify the subscription and delivery route with the responsible operator. Document whether the response is to pause a scheduler, investigate a changed query, or have an authorized administrator disable the workgroup. Disabling a workgroup affects its consumers, so define the recovery owner too.

Concurrent queries explain why both controls matter. Four queries scanning 4 GB each can all remain below a 5 GB per-query cutoff while collectively crossing a 10 GB alert threshold. These are illustrative decimal units. The aggregate alert reports the crossing; it does not reserve a remaining allowance before each query starts.

AWS also says canceled queries are charged according to Athena pricing. Therefore, describe the cutoff as a scan control, not a guaranteed dollar ceiling or a promise that cancellation is free. An alert response has its own delay and operational dependencies.

Read back the configuration and the actual execution

Use an AWS CLI profile authorized to read the workgroup and query metadata. The following commands only retrieve information. Replace the Region, workgroup name, and execution ID with your approved values.

The GetWorkGroup API reference exposes the byte cutoff and metrics configuration. Read the stored value after saving the setting:

ATHENA_REGION="us-east-1"
ATHENA_WORKGROUP="ai-cost-reporting"

aws athena get-work-group \
  --region "$ATHENA_REGION" \
  --work-group "$ATHENA_WORKGROUP" \
  --query 'WorkGroup.{name:Name,state:State,cutoff_bytes:Configuration.BytesScannedCutoffPerQuery,metrics:Configuration.PublishCloudWatchMetricsEnabled}' \
  --output json

Expected result: the intended name, an enabled workgroup, the approved numeric cutoff in bytes, and the metrics setting required by your monitoring setup. Compare bytes with the approved configuration rather than assuming how a console label converts GB to GiB. Separately inspect the aggregate alert’s period, threshold, SNS destination, and enabled alarm action; this API projection does not establish those settings or successful notification delivery.

After an approved test query finishes, inspect its execution rather than relying on the submitter’s local configuration. The get-query-execution CLI reference documents workgroup identity, status, scanned bytes, effective engine version, and result reuse information:

ATHENA_QUERY_ID="replace-with-query-execution-id"

aws athena get-query-execution \
  --region "$ATHENA_REGION" \
  --query-execution-id "$ATHENA_QUERY_ID" \
  --query 'QueryExecution.{id:QueryExecutionId,workgroup:WorkGroup,state:Status.State,reason:Status.StateChangeReason,scan_bytes:Statistics.DataScannedInBytes,reused:Statistics.ResultReuseInformation.ReusedPreviousResult,engine:EngineVersion.EffectiveEngineVersion}' \
  --output json

Expected result: the recorded execution ID belongs to ai-cost-reporting, reaches a terminal state, and includes the relevant statistics. A successful metadata read while the query remains queued or running is not completion evidence. Keep missing statistics unresolved rather than replacing them with zero.

Check reused when evaluating scan behavior. A reused previous result does not exercise a fresh scan in the same way. For the cutoff test, configure a fresh execution and verify that a previous result was not reused. Keep the normal report’s reuse policy as a separate decision about acceptable data freshness.

These commands are documentation-based examples. No authenticated AWS query, workgroup change, or paid scan was performed for this article.

Budget the executions that the schedule creates

For on-demand SQL, forecast billable scanned volume per execution and multiply by the applicable regional rate. Count refreshes, additional dashboard queries, backfills, and resubmissions individually. A small output table does not establish how much input the engine read.

forecast query charge = sum of billable TB per execution × applicable price per TB

For illustration, assume 120 executions, each billed for 0.02 TB, at an assumed $5 per TB. The query subtotal is $12. If a dashboard change creates four executions for every scheduled refresh, the subtotal becomes $48. The amounts are planning examples, not a regional quote or an observed bill. Apply the current rounding and minimum-charge rules for the selected billing mode before aggregating.

The Athena pricing page demonstrates why file layout and selected columns matter. Its example reduces scanning through compression, then reduces it further when a Parquet query reads one of four columns. Use measured DataScannedInBytes to evaluate a proposed change against the same accepted input snapshot. Do not assume a particular compression ratio for your billing dataset.

Keep the financial result constant during that comparison. Check source row coverage, currencies, signed adjustments, and report totals before accepting a lower scan count. The site’s SQL join fanout guide covers totals that change when billing rows gain multiple matches. Use the export snapshot replacement workflow to pin one coherent delivery before comparing executions.

Add S3 storage, requests, and applicable transfer charges, plus Glue Data Catalog charges where used, to the reporting forecast. AWS lists these separately from Athena SQL pricing. If you introduce a federated source, review its additional Lambda and scan charges before reusing this S3-only estimate.

Prove the cutoff and alert on bounded fixtures

Use a sandbox workgroup and non-sensitive fixture data. Choose a small approved testing allowance, and first establish the fixture’s scan size under controlled conditions. Do not test by removing filters from an entire production billing archive.

CheckExpected observation
Ordinary report below the cutoffCompletes in the intended workgroup; totals reconcile; scanned bytes are recorded
Fresh fixture scan above a deliberately low test cutoffAthena stops the execution because it exceeded the scan limit; retain the terminal state and reason
Several individually permitted scans cross the aggregate thresholdThe configured alert reaches its owner; queries are not automatically canceled by that alert
Reporting role attempts the same submission through an unapproved workgroupAuthorization prevents it if workgroup isolation is required by policy
A scheduler requests another execution after a cutoff failureThe application holds it for diagnosis rather than looping unchanged queries
A previous result is reusedThe record identifies reuse and is excluded from evidence for a fresh-scan cutoff test

These are acceptance criteria to run in your environment, not reported test outcomes. Budget the intentional canceled scan too. If the execution fails for an unrelated reason, such as missing result-bucket access, it has not demonstrated the cutoff. Repair the fixture or permissions and repeat only the bounded case.

For an oversized query, inspect the input snapshot, selected fields, and query revision before increasing the threshold. If an aggregate alert fires while every individual query is small, inspect execution count and overlapping schedules. Raising the per-query cutoff does not address excessive repetition.

For S3-backed results, AWS warns that canceled or failed queries can leave partial results and incomplete multipart uploads. Apply the approved cleanup and lifecycle policy to the correct output prefix. A cancellation should not leave unreviewed storage accumulating indefinitely.

Retain the query revision, snapshot reference, workgroup, execution ID, terminal state, scanned bytes, reuse flag, configured cutoff, alert period, and operator response. Shared records need neither raw billing rows nor SQL text containing sensitive literals.

Sources checked

Five primary AWS references returned HTTP 200 on November 19, 2026 UTC. These maintained technical references support an evergreen operating task; no page-specific revision date was visible in the retrieved text. Confirm the Region’s current pricing and the account’s configuration before applying the example.

Start with one scheduled AI cost report: record its workgroup and normal scan size, set an approved cutoff, and name the aggregate alert’s owner. Approve the control only after the bounded cutoff case, notification delivery, and report-total reconciliation all produce the expected evidence.