Radar System Observability Guide
Overview
The Radar system now includes comprehensive logging, monitoring, and tracing capabilities to help you understand system behavior, diagnose issues, and track why certain radars may not be running as expected.Logging Enhancements
Structured JSON Logging
All Lambda functions now use structured JSON logging with consistent fields:Key Log Fields
Common Fields:timestamp- ISO 8601 timestamplevel- Log level (INFO, WARNING, ERROR, DEBUG)message- Human-readable descriptionexecution_id- Unique ID for tracking across serviceslambda_request_id- AWS Lambda request ID
target_date- Date for which schedules are being processedschedules_found- Number of schedules duequeued_count- Number successfully queuedfailed_count- Number that failed to queuebatch_number- SQS batch numberuser_id- User ID from scheduleschedule_id- Unique schedule identifierradar_type- Type of radarenabled- Whether schedule is enabled
record_index- Position in batchapi_duration_ms- Time spent calling chat APImodel_used- AI model usedinput_tokens/output_tokens- Token usagetool_calls_count- Number of tool calls madeprocessing_time_ms- Total processing timenext_run- Calculated next run time
request_id- Unique request IDhttp_method- HTTP method (GET, POST, etc.)path- API endpoint pathoperation- Specific operation performedoperation_duration_ms- Operation duration
Viewing Logs in CloudWatch
CloudWatch Log Groups
Each Lambda function has its own log group:/aws/lambda/{env}-RadarOrchestrator/aws/lambda/{env}-RadarProcessor/aws/lambda/{env}-RadarAPI
Useful CloudWatch Insights Queries
1. Find Why Schedules Didn’t Run
2. Track Execution Performance
3. Find Processor Errors
4. Track API Call Performance
5. Monitor Token Usage
6. Find All Errors with Full Context
7. Track Schedule Processing Rate
8. Monitor DynamoDB Operations
CloudWatch Alarms
The system includes automatic alarms for:1. Orchestrator Errors
- Alarm:
{env}-radar-orchestrator-errors - Threshold: 1 error in 5 minutes
- Action: Investigate why schedules aren’t being queued
2. Processor Errors
- Alarm:
{env}-radar-processor-errors - Threshold: 3 errors in 10 minutes (2 consecutive periods)
- Action: Check DLQ and investigate failed radar executions
3. Dead Letter Queue Messages
- Alarm:
{env}-radar-dlq-messages - Threshold: Any message in DLQ
- Action: Messages failed after 3 retries - manual investigation required
4. API Gateway Errors
- Alarm:
{env}-radar-api-errors - Threshold: 5 errors in 10 minutes (2 consecutive periods)
- Action: Check API logs for client or server errors
X-Ray Tracing
AWS X-Ray is enabled on all Lambda functions for distributed tracing.Viewing X-Ray Traces
- Go to AWS X-Ray Console
- Select “Service Map” to see system architecture
- Select “Traces” to view individual executions
- Filter by:
- Service name:
radar-orchestrator,radar-processor,radar-api - HTTP status code
- Response time
- Error status
- Service name:
X-Ray Segments
Each Lambda execution creates segments showing:- Lambda invocation duration
- DynamoDB operations
- SQS operations
- External HTTP calls (chat API)
- Subsegment timing
Troubleshooting Common Issues
Issue: Radar Not Running
Steps:- Check CloudWatch logs for orchestrator around 6am UTC
- Search for:
message = "Schedule queued for processing" AND schedule_id = "your-schedule-id" - Look for:
enabled = false- Schedule is disablednext_rundate mismatch - Schedule not due yet- Missing schedule - Not in query results
Issue: Radar Processing Failed
Steps:- Check processor logs for errors
- Look for the
execution_idin traceback - Check if message ended up in DLQ
Issue: Slow Performance
Steps:- Check X-Ray traces for bottlenecks
- Review API call durations
- Check DynamoDB query performance
Issue: High Token Usage
Query:Metrics Dashboard
Create a CloudWatch Dashboard with:-
Orchestrator Metrics:
- Lambda invocations
- Duration
- Errors
- Schedules queued per execution
-
Processor Metrics:
- Lambda invocations (from SQS)
- Duration
- Errors
- API call latency
- Token usage
-
API Metrics:
- Request count by endpoint
- Latency by endpoint
- 4xx/5xx errors
- Request rate
-
Queue Metrics:
- Messages in queue
- Messages in DLQ
- Age of oldest message
Best Practices
-
Regular Monitoring:
- Check CloudWatch dashboards daily
- Review alarms weekly
- Analyze token usage monthly
-
Log Retention:
- Logs retained for 2 weeks
- Export important logs to S3 for long-term storage
- Create metric filters for key events
-
Alarm Actions:
- Set up SNS topics for alarm notifications
- Create runbooks for each alarm type
- Test alarm thresholds regularly
-
Performance Optimization:
- Monitor API call durations
- Track DynamoDB query performance
- Review batch processing efficiency
Example: Complete Investigation Flow
Scenario: User reports their daily portfolio check radar stopped running- Find the schedule:
- Check if it was queued:
- Check processing status:
-
Review full execution trace:
- Go to X-Ray Console
- Filter by execution_id
- Review timing and errors
-
Check DLQ:
- View SQS DLQ in AWS Console
- Check for failed messages
- Review failure reasons
Support
For additional help:- Review X-Ray service map for architecture overview
- Check CloudWatch metrics for system health
- Analyze structured logs for detailed execution flow
- Monitor alarms for proactive issue detection