Source Code
- Navigate to your cloned Watchlog Agent repository:
cd /path/to/watchlog-agent - Open the log-watchlist configuration file:
vim log-watchlist.json - Define the logs you want to monitor. For example:
{ "logs": [ { "name": "Nginx Access Logs", "path": "/var/log/nginx/access.log", "service": "nginx", "format": "auto" }, { "name": "Redis Logs", "path": "/var/log/redis/redis.log", "service": "redis", "format": "custom", "pattern": "^(\\d{2} \\w{3} \\d{2}:\\d{2}:\\d{2}) (\\w+): (.*)$" } ] } - Explanation of fields:
name: A friendly name for this log stream.path: Full filesystem path to the log file.service: The service name used for categorization.format:auto: Watchlist auto-detects common log formats.custom: Use thepatternfield to define a regular expression.
pattern: A regex with three capture groups for:- Date/Time
- Log Level (e.g., INFO, ERROR, DEBUG)
- Message content.
- Save the file and reload the agent:
sudo pm2 reload watchlog-agent
