Amazon Bedrock tokenomics data lake
Amazon Bedrock now has a centralized observability data lake that aggregates raw invocation logs from linked accounts into a single, queryable Athena table. The solution uses CloudFormation‑deployed Lambda, CloudWatch subscription filters, and Kinesis Data Firehose to flatten prompts, responses, token counts, model IDs, stop reasons, timestamps, and IAM roles into a unified view. Engineers can instantly query per‑invocation costs and debug usage across the organization.
⚡ Key Takeaways
- The processed Athena table includes prompt text, model response, input and output token counts, model name, stop reason, account ID, timestamp, and IAM role per invocation.
- Architecture relies on CloudWatch subscription filters forwarding logs to a central account, then Kinesis Data Firehose delivering to S3 for Athena querying.
- Centralized view eliminates the need to manually aggregate logs across accounts, reducing debugging latency and spotting wasteful prompts.
- Deploy the solution with two AWS CloudFormation templates provided in the AWS Sample Bedrock Invocation Data Lake GitHub repo.
- Requires enabling Bedrock model invocation logging in each source AWS account and linking those accounts to the central account.
Engineers can now attribute token usage and costs to specific prompts and teams in real time, enabling precise optimization and billing accountability for large‑scale Bedrock deployments.
✅ Practical Steps
- Enable Bedrock model invocation logging in each AWS account’s Bedrock settings.
- Deploy the two CloudFormation templates from the AWS Sample Bedrock Invocation Data Lake GitHub repository to set up the Lambda, CloudWatch subscription filters, and Kinesis Data Firehose pipeline.
- Query the consolidated Athena table to retrieve per‑invocation details such as prompt, token counts, and cost.
Want the full story? Read the original article.
Read on AWS ML Blog ↗