log-monitoring
Log Monitoring
Monitor current logs across the OpenAlgo system in real-time. Track log file sizes, watch for new entries, detect log rotation, and check log health.
Log Sources
System Logs
- Location:
openalgo/log/ - Pattern:
openalgo_YYYY-MM-DD.log(daily rotation) - Rotation: Midnight rotation, retains 14 days (configurable via
LOG_RETENTION) - Max Size: 10 MB per file before rotation
Strategy Logs
- Location:
openalgo/strategies/logs/oropenalgo/log/strategies/ - Pattern:
{strategy_id}_*.log - Access: Web UI at
/python/logs/<strategy_id> - Reports:
strategy_report_*.txtfor daily summaries
Web UI Logs
- Endpoint:
/logs(filterable, searchable) - Streaming: SSE endpoint for real-time log streaming
Monitoring Workflow
1. Check Log Status
# List all log files with sizes
find openalgo/log -name "*.log*" -type f -exec ls -lh {} \;
find openalgo/strategies/logs -name "*.log" -type f -exec ls -lh {} \;
# Check current log file size
ls -lh openalgo/log/openalgo_*.log | tail -1
# Count log files
find openalgo/log -name "*.log*" | wc -l
2. Monitor Logs in Real-Time
# System logs (follow latest)
tail -f openalgo/log/openalgo_$(date +%Y-%m-%d).log
# Strategy-specific log
tail -f openalgo/strategies/logs/{strategy_id}_*.log
# Multiple logs simultaneously
tail -f openalgo/log/openalgo_*.log openalgo/strategies/logs/*.log
# Last N lines then follow
tail -n 100 -f openalgo/log/openalgo_*.log
3. Watch for Errors
# Monitor for errors in real-time
tail -f openalgo/log/openalgo_*.log | grep -iE "ERROR|WARNING|CRITICAL|exception|traceback"
# Monitor specific strategy for errors
tail -f openalgo/strategies/logs/{strategy_id}_*.log | grep -iE "ERROR|403|429|400"
# Count errors in recent logs
grep -iE "ERROR|CRITICAL" openalgo/log/openalgo_*.log | wc -l
4. Check Log Health
# Verify log rotation is working
ls -lh openalgo/log/openalgo_*.log | tail -5
# Check if logs are being written (recent modification)
find openalgo/log -name "*.log" -mmin -5
# Verify log directory permissions
ls -ld openalgo/log openalgo/strategies/logs
# Check disk space used by logs
du -sh openalgo/log openalgo/strategies/logs
Common Monitoring Patterns
Monitor All Active Strategies
# Find all active strategy log files
find openalgo/strategies/logs -name "*.log" -mmin -60 -type f
# Monitor all active strategy logs
find openalgo/strategies/logs -name "*.log" -mmin -60 -type f -exec tail -f {} +
Track Log Growth
# Watch log file size growth
watch -n 5 'ls -lh openalgo/log/openalgo_*.log | tail -1'
# Check which logs are growing fastest
find openalgo/log openalgo/strategies/logs -name "*.log" -type f -exec sh -c 'echo "$(du -h "$1" | cut -f1) $1"' _ {} \; | sort -hr | head -10
Monitor Log Rotation
# Check rotation status
ls -lh openalgo/log/openalgo_*.log | tail -15
# Verify rotation count matches retention setting
ls openalgo/log/openalgo_*.log* | wc -l
Log Monitoring Scripts
Quick Status Check
#!/bin/bash
# Check current log status
echo "=== System Logs ==="
ls -lh openalgo/log/openalgo_*.log | tail -3
echo ""
echo "=== Strategy Logs ==="
find openalgo/strategies/logs -name "*.log" -mmin -60 -type f | head -10
echo ""
echo "=== Recent Errors ==="
grep -iE "ERROR|CRITICAL" openalgo/log/openalgo_$(date +%Y-%m-%d).log | tail -5
Continuous Monitoring
#!/bin/bash
# Monitor logs with error highlighting
tail -f openalgo/log/openalgo_$(date +%Y-%m-%d).log | \
while IFS= read -r line; do
if echo "$line" | grep -qiE "ERROR|CRITICAL"; then
echo -e "\033[31m$line\033[0m" # Red for errors
elif echo "$line" | grep -qiE "WARNING"; then
echo -e "\033[33m$line\033[0m" # Yellow for warnings
else
echo "$line"
fi
done
Web UI Monitoring
- Log Viewer: Access at
http://localhost:5000/logs - Strategy Logs: Access at
http://localhost:5000/python/logs/<strategy_id> - Features: Filter by level, search, date range, download
Monitoring Best Practices
- Check log rotation: Ensure logs rotate properly and don't fill disk
- Monitor error rates: Track ERROR/CRITICAL frequency over time
- Watch file sizes: Alert if logs exceed expected sizes
- Verify write access: Ensure processes can write to log directories
- Track log growth: Monitor disk space usage by logs
- Check timestamps: Verify logs are being written recently
Output Format
When monitoring logs, provide:
- Current Status: Active log files and their sizes
- Recent Activity: Last modification times
- Error Summary: Count of recent errors/warnings
- Health Check: Rotation status, disk usage, permissions
- Recommendations: Any issues or optimizations needed
Integration with Other Skills
- Use
log-analyzerfor detailed error analysis - Use
log-drain-monitorfor observability stack setup - Use
trading-operationsfor strategy-specific log monitoring
More from sayujks0071/antidhan
trading-strategy-development
Create and modify trading strategies for OpenAlgo with proper structure, risk management, entry/exit logic, and position management. Use when developing new strategies, modifying existing ones, debugging strategy logic, or implementing trading signals.
12risk-management
Implement and review risk controls, position sizing, portfolio heat limits, stop losses, and risk monitoring. Use when implementing risk management, reviewing risk controls, calculating position sizes, or analyzing portfolio risk exposure.
7trading-operations
Daily trading operations, monitoring, troubleshooting, deployment, and system health checks. Use when starting trading sessions, monitoring strategies, troubleshooting issues, checking system status, or deploying strategies.
7pr-49-review
Reviews pull request #49 for OpenAlgo observability changes, focusing on risks, security, and test coverage. Use when analyzing PR #49 or when the user asks about the local observability stack changes.
6plan-based-skill-builder
Builds Cursor skills from plan documents by analyzing workflows, extracting key instructions, and creating structured skill files. Use when creating skills from restart plans, deployment plans, prioritization plans, retest plans, or any structured plan documents.
6backtesting-analysis
Run backtests, analyze strategy performance, compare strategies, and generate ranking reports. Use when backtesting strategies, analyzing performance metrics, comparing strategy variants, or generating backtest reports.
6