You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add comprehensive CloudWatch dashboard for monitoring
Implements a complete CloudWatch dashboard with custom Lambda-powered widgets for real-time
monitoring and visualization of usage metrics. The dashboard provides comprehensive insights
into token consumption, user activity, code effectiveness, and cost tracking.
Key Features:
- DynamoDB single-table design for efficient metrics storage
- 10+ custom dashboard widgets with responsive layouts
- Real-time token usage and cost tracking
- User activity monitoring and analytics
- Code acceptance rate tracking
- Cache efficiency metrics
- Operations breakdown by type
- Lambda layer architecture for shared utilities
Technical Implementation:
- EventBridge scheduled metrics aggregation every 5 minutes
- Lambda functions for custom widget rendering
- DynamoDB TTL for automatic 30-day data retention
- Support for 10,000+ users with sub-second response times
Copy file name to clipboardExpand all lines: assets/docs/MONITORING.md
+3-29Lines changed: 3 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,6 @@ When you enable monitoring during deployment, the system creates infrastructure
8
8
9
9
The monitoring system consists of several components working together. Claude Code sends metrics using the OpenTelemetry Protocol (OTLP) to an Application Load Balancer. The ALB forwards these metrics to an OTEL Collector running on ECS Fargate. The collector then converts the metrics to CloudWatch's Embedded Metric Format (EMF) and sends them to CloudWatch Metrics and Logs. Finally, a CloudWatch Dashboard visualizes these metrics.
10
10
11
-
The OTEL Collector serves as a critical bridge because CloudWatch doesn't support OTLP metrics directly. Claude Code uses the industry-standard OTLP format, while CloudWatch requires its proprietary EMF format. The collector handles this translation, ensuring metrics flow smoothly from Claude Code to your CloudWatch dashboards.
12
-
13
11
## Implementation Details
14
12
15
13
The monitoring infrastructure deploys several AWS resources to handle metric collection and visualization.
@@ -18,7 +16,7 @@ The core component runs as an ECS Fargate service using the AWS Distro for OpenT
18
16
19
17
An Application Load Balancer sits in front of the ECS service, receiving OTLP metrics on port 4318. The ALB supports both HTTP and HTTPS protocols. When you provide a custom domain name during deployment, the system automatically creates an ACM certificate and configures HTTPS. Health checks monitor the collector's availability through the root endpoint.
20
18
21
-
The CloudWatch Dashboard provides comprehensive visualization of your Claude Code usage. It displays metrics by user, tracks token consumption for both input and output, shows request counts broken down by model, monitors error rates and latency, and includes cost estimation widgets to help track spending.
19
+
The CloudWatch Dashboard provides comprehensive visualization of your Claude Code usage. The dashboard uses Lambda functions and DynamoDB for efficient metrics collection and display, presenting real-time and historical usage data through custom widgets.
22
20
23
21
### Configuration
24
22
@@ -56,14 +54,6 @@ The deployment creates the complete monitoring infrastructure: a VPC with public
56
54
57
55
If you provide a custom domain name and hosted zone ID during setup, the system automatically provisions an ACM certificate and configures HTTPS. This ensures encrypted transmission of metrics from Claude Code to your collector.
58
56
59
-
After deployment completes, the package command handles all the configuration needed for end users:
60
-
61
-
```bash
62
-
poetry run ccwb package
63
-
```
64
-
65
-
This creates a distribution folder containing the credential process executable, configuration files, installation script, Claude Code telemetry settings, and platform-specific OTEL helper binaries that extract user attributes from authentication tokens.
66
-
67
57
## Claude Code Configuration
68
58
69
59
The package command generates a `.claude/settings.json` file that configures Claude Code for telemetry collection. This file gets installed to the user's home directory and contains all the settings needed for monitoring.
@@ -105,13 +95,8 @@ Organizational dimensions provide additional context. The `department` field gro
105
95
106
96
The CloudWatch Dashboard named `ClaudeCodeMonitoring` provides comprehensive visualization of your Claude Code metrics.
107
97
108
-
The dashboard displays token usage metrics in multiple formats. Total token usage appears as time series graphs showing 5-minute and hourly intervals. Token breakdown by type (input, output, cache creation, cache read) helps you understand usage patterns. The dashboard includes pie charts showing token distribution over 30-day periods and stacked time series for analyzing trends.
109
-
110
-
Cost tracking features estimate expenses based on token consumption. The dashboard calculates hourly costs using the configurable token price parameter (default $15 per million tokens). Single value widgets show today's cost, this week's cost, and this month's total cost. Time series graphs track cost trends with budget threshold annotations.
111
-
112
-
Session and activity metrics track active sessions per hour, helping you understand usage patterns throughout the day. The dashboard also monitors Bedrock API calls broken down by model (Sonnet, Haiku, Opus), showing which models your users prefer.
113
-
114
-
For detailed user analytics, the dashboard includes a section that directs you to AWS Athena. While the dashboard shows aggregate metrics, Athena queries enable user-specific analysis including top users by token consumption, usage by department or team, and cost allocation by user. The system stores pre-built queries in SSM Parameter Store for common analytics tasks.
@@ -131,17 +116,6 @@ CloudTrail tracking captures every Bedrock model invocation, storing detailed lo
131
116
132
117
The monitoring dashboard includes several cost-related features. A separate Bedrock cost dashboard tracks AWS Billing charges for the Bedrock service. The main dashboard estimates costs based on token usage with configurable pricing (default $15 per million tokens). Real-time cost widgets show today's cost, this week's cost, and this month's total spending.
133
118
134
-
The system includes pre-configured CloudWatch alarms for cost control:
135
-
136
-
-**High Token Usage**: Alerts when usage exceeds 10 million tokens per hour
137
-
-**Daily Token Threshold**: Triggers when daily usage exceeds approximately $1000 worth of tokens (66.7 million tokens at default pricing)
138
-
-**High Bedrock Usage**: Alerts when Bedrock API calls exceed 1000 per hour
139
-
-**Unusual Model Usage**: Monitors expensive model usage, alerting when it exceeds 50 million tokens per hour
140
-
141
-
Bedrock tracking is enabled by default in the authentication stack. To disable it during deployment, set the CloudFormation parameter `EnableBedrockTracking` to false.
142
-
143
-
The monitoring system tracks costs through multiple mechanisms. Token-based estimation provides immediate feedback on usage costs. The Bedrock cost dashboard shows actual AWS Billing charges for the Bedrock service. CloudWatch alarms help prevent unexpected spending by alerting on unusual usage patterns.
144
-
145
119
### Data Privacy
146
120
147
121
The system collects only usage metrics, never capturing or transmitting conversation content between users and Claude. User attribution works through the email address from the OIDC token, providing clear accountability without excessive data collection. CloudWatch retains metrics for 15 months by default, though you can adjust this based on your retention policies. Beyond the email address used for attribution, no personally identifiable information is transmitted or stored.
0 commit comments