A powerful and intuitive command-line tool for interacting with AWS CloudWatch Logs. Stream logs in real-time, query historical data, and manage log groups with ease.
- Real-time log streaming - Tail logs from CloudWatch in real-time
- Historical queries - Search through past logs with time ranges
- Time range support - Use flexible time formats (
--since 1h,--start,--end) - String filtering - Filter logs with simple patterns or CloudWatch filter syntax
- List log groups - Browse available log groups with pattern matching
- Colored output - Enhanced readability with syntax highlighting
- Progress indicators - Visual feedback during operations
- AWS profile support - Switch between multiple AWS accounts
- Formatted table output - Dynamic column detection with intelligent sorting
# Clone the repository
git clone https://github.com/yourusername/cwl.git
cd cwl
# Build the project
cargo build --release
# Install to your PATH
cargo install --path .# List all log groups
cwl groups
# Filter log groups
cwl groups --filter "production"# Tail logs (last 5 minutes)
cwl tail /aws/lambda/my-function
# Follow logs continuously
cwl tail /aws/lambda/my-function --follow
# Filter while tailing
cwl tail /aws/lambda/my-function --filter "ERROR" --highlight# Query logs from the last hour
cwl query /aws/lambda/my-function --since 1h
# Query with specific time range
cwl query /aws/lambda/my-function --start "2024-01-01 10:00:00" --end "2024-01-01 12:00:00"
# Query with filter and limit
cwl query /aws/lambda/my-function --filter "user_id=12345" --limit 500
# Query with formatted table output (auto-detects JSON structure)
cwl query /aws/lambda/my-function --since 1h --formattedThe --formatted flag automatically parses JSON log entries and displays them in a dynamic table:
# View logs as a formatted table with all JSON fields as columns
cwl query /aws/lambda/my-function --formatted --since 1h
# Combine with filters for focused analysis
cwl query /aws/ecs/my-app --formatted --filter "ERROR" --limit 100Features of formatted output:
- Automatically detects all JSON fields across log entries
- Uses dot notation for nested fields (e.g.,
payload.message,user.id) - Sorts columns by frequency (most common fields appear leftmost)
- Calculates optimal column widths
- Truncates long values with ellipsis
- Colored headers and separators for clarity
Example output:
timestamp │ log_group │ level │ message │ payload.error
────────────────────────┼───────────────┼───────┼──────────────┼───────────────
2024-01-01 10:15:23.456 │ my-app │ ERROR │ Failed auth │ Invalid token
2024-01-01 10:15:24.789 │ my-app │ WARN │ Retry attempt│ Connection timeout
The tool supports multiple time formats:
- Relative time:
--since 1h,--since 30m,--since 2d - ISO 8601:
--start 2024-01-01T10:00:00Z - Human-readable:
--start "2024-01-01 10:00:00" - Unix timestamps:
--start 1704103200
# Use a specific AWS profile
cwl tail /aws/lambda/my-function --profile production
# Use a specific region
cwl tail /aws/lambda/my-function --region us-west-2The tool respects standard AWS environment variables:
AWS_PROFILEAWS_REGIONAWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY
# Stream errors from multiple Lambda functions
cwl tail /aws/lambda/prod-api --filter "ERROR" --follow --highlight# Find all logs for a specific user in the last 24 hours
cwl query /aws/ecs/my-app --since 24h --filter "user_id=abc123"# Check recent logs (last 5 minutes by default)
cwl tail /aws/lambda/my-functionCreate a configuration file at ~/.config/cwl/config.toml:
[defaults]
region = "us-east-1"
output = "colored"
max_events = 1000
[profiles.production]
assume_role = "arn:aws:iam::123456789:role/ProdReader"
region = "us-west-2"
[aliases]
lambda-errors = "query /aws/lambda/* --filter ERROR --since 1h"Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details
Built with:
- aws-sdk-rust - AWS SDK for Rust
- clap - Command-line argument parser
- tokio - Async runtime
- colored - Terminal colors
- indicatif - Progress indicators