Skip to main content

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 timestamp
  • level - Log level (INFO, WARNING, ERROR, DEBUG)
  • message - Human-readable description
  • execution_id - Unique ID for tracking across services
  • lambda_request_id - AWS Lambda request ID
Orchestrator-Specific:
  • target_date - Date for which schedules are being processed
  • schedules_found - Number of schedules due
  • queued_count - Number successfully queued
  • failed_count - Number that failed to queue
  • batch_number - SQS batch number
  • user_id - User ID from schedule
  • schedule_id - Unique schedule identifier
  • radar_type - Type of radar
  • enabled - Whether schedule is enabled
Processor-Specific:
  • record_index - Position in batch
  • api_duration_ms - Time spent calling chat API
  • model_used - AI model used
  • input_tokens / output_tokens - Token usage
  • tool_calls_count - Number of tool calls made
  • processing_time_ms - Total processing time
  • next_run - Calculated next run time
API-Specific:
  • request_id - Unique request ID
  • http_method - HTTP method (GET, POST, etc.)
  • path - API endpoint path
  • operation - Specific operation performed
  • operation_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
Logs are retained for 2 weeks by default.

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

  1. Go to AWS X-Ray Console
  2. Select “Service Map” to see system architecture
  3. Select “Traces” to view individual executions
  4. Filter by:
    • Service name: radar-orchestrator, radar-processor, radar-api
    • HTTP status code
    • Response time
    • Error status

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:
  1. Check CloudWatch logs for orchestrator around 6am UTC
  2. Search for: message = "Schedule queued for processing" AND schedule_id = "your-schedule-id"
  3. Look for:
    • enabled = false - Schedule is disabled
    • next_run date mismatch - Schedule not due yet
    • Missing schedule - Not in query results
Query:

Issue: Radar Processing Failed

Steps:
  1. Check processor logs for errors
  2. Look for the execution_id in traceback
  3. Check if message ended up in DLQ
Query:

Issue: Slow Performance

Steps:
  1. Check X-Ray traces for bottlenecks
  2. Review API call durations
  3. Check DynamoDB query performance
Query:

Issue: High Token Usage

Query:

Metrics Dashboard

Create a CloudWatch Dashboard with:
  1. Orchestrator Metrics:
    • Lambda invocations
    • Duration
    • Errors
    • Schedules queued per execution
  2. Processor Metrics:
    • Lambda invocations (from SQS)
    • Duration
    • Errors
    • API call latency
    • Token usage
  3. API Metrics:
    • Request count by endpoint
    • Latency by endpoint
    • 4xx/5xx errors
    • Request rate
  4. Queue Metrics:
    • Messages in queue
    • Messages in DLQ
    • Age of oldest message

Best Practices

  1. Regular Monitoring:
    • Check CloudWatch dashboards daily
    • Review alarms weekly
    • Analyze token usage monthly
  2. Log Retention:
    • Logs retained for 2 weeks
    • Export important logs to S3 for long-term storage
    • Create metric filters for key events
  3. Alarm Actions:
    • Set up SNS topics for alarm notifications
    • Create runbooks for each alarm type
    • Test alarm thresholds regularly
  4. 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
  1. Find the schedule:
  1. Check if it was queued:
  1. Check processing status:
  1. Review full execution trace:
    • Go to X-Ray Console
    • Filter by execution_id
    • Review timing and errors
  2. 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