Overview
Carrier provides comprehensive logging and monitoring capabilities to help you track message processing, resource usage, and system health in production environments.JSON Logging
Structured logs for easy parsing and analysis
Colorized Output
Human-friendly logs for local development
Statistics Tracking
Periodic resource usage reports
Source Attribution
Every log includes component identification
Logging Configuration
Carrier supports two logging formats controlled by environment variables:JSON Logging (Production)
Default format for production environments. Each log entry is a valid JSON object:Colorized Logging (Development)
Human-friendly format for local development and debugging:Implementation
Logging is configured inmain.go:84-92:
slog) with source attribution:
Statistics Logging
Enable periodic statistics reporting to track resource usage:StatLogger Implementation
The StatLogger component (main.go:42-78) tracks goroutines and memory usage:
Stats Output Example
JSON format:The StatLogger uses the
humanize library to format memory sizes in human-readable units (MB, GB, etc.).Log Levels and Sources
Log Levels
Carrier uses standard log levels:| Level | Usage | Examples |
|---|---|---|
INFO | Normal operation events | Startup, shutdown, state changes |
WARN | Potential issues | Webhook offline, configuration warnings |
ERROR | Error conditions | Failed API calls, transmission failures |
DEBUG | Detailed diagnostics | Message counts, batch operations |
Log Sources
Each log entry includes asource field identifying the component:
| Source | Component | Purpose |
|---|---|---|
main | Main process | Startup, shutdown, configuration |
main.StatLogger | Statistics logger | Resource usage tracking |
sqs.Receiver | SQS receiver | Message polling and processing |
webhook.Transmitter | HTTP transmitter | Webhook delivery (logged at debug level in errors) |
webhook.HealthChecker | Health checker | Endpoint health monitoring |
Production Monitoring Setup
Docker Compose Example
Kubernetes Example
Integration with Monitoring Tools
CloudWatch Logs
When running on AWS ECS or EKS, logs are automatically sent to CloudWatch:Datadog
Configure the Datadog Agent to parse Carrier’s JSON logs:Prometheus
While Carrier doesn’t expose metrics directly, you can use a log-to-metrics exporter:Grafana Loki
Query Carrier logs in Loki:Elasticsearch (ELK Stack)
Index Carrier logs with Filebeat:Key Metrics to Monitor
Message Throughput
Track
deleted messages count to measure successful processing rateError Rate
Monitor
failed to transmit message errors for processing issuesMemory Usage
Watch
memory values in stats logs for memory leaksGoroutine Count
Track
goroutines to detect goroutine leaksHealth Status
Monitor
webhook online/offline events for service healthVisibility Updates
Track
updated message visibility for retry pattern analysisSample Monitoring Queries
- Message Processing
- Error Tracking
- Resource Usage
- Health Events
CloudWatch Logs Insights
Loki
Alerting Recommendations
High Error Rate
High Error Rate
Condition: More than 5 transmission errors in 5 minutesAction:
- Check webhook service health
- Review recent code deployments
- Verify network connectivity
Webhook Offline
Webhook Offline
Condition: Webhook marked as offlineAction:
- Check worker service status
- Review worker logs for errors
- Verify health check endpoint
Memory Growth
Memory Growth
Condition: Memory usage increasing over timeAction:
- Review memory stats trends
- Check for message processing backlog
- Consider restarting the container
Goroutine Leak
Goroutine Leak
Condition: Goroutine count continuously increasingAction:
- Check for stuck message processing
- Review recent configuration changes
- Restart the container if count exceeds threshold
Best Practices
Use JSON in Production
Always use JSON logging (
CARRIER_ENABLE_COLORIZED_LOGGING=false) in production for better parsing and analysis.Enable Stats Logging
Set
CARRIER_ENABLE_STAT_LOG=true to track resource usage trends over time.Configure Log Rotation
Use container logging drivers with size and file limits to prevent disk space issues.
Correlate Logs
Use message IDs from SQS to correlate logs across Carrier and your worker application.
Set Up Alerts
Create alerts for error rates, webhook offline events, and resource anomalies.
Monitor Trends
Track message throughput, error rates, and resource usage trends over time.
Troubleshooting
No Logs Appearing
- Verify logs are being written to stdout:
docker logs <container> - Check log aggregation configuration
- Ensure JSON parsing is configured correctly
Missing Stats Logs
- Confirm
CARRIER_ENABLE_STAT_LOG=true - Check
CARRIER_STAT_LOG_TIMERvalue - Verify the StatLogger goroutine is running
Log Volume Too High
- Increase
CARRIER_STAT_LOG_TIMERfor less frequent stats - Filter out debug-level logs in your aggregation tool
- Increase batch size to reduce per-message log entries
Related Topics
Health Checks
Configure webhook health monitoring
Dynamic Timeouts
Implement intelligent retry strategies
Configuration
Complete environment variable reference
