Watchlog Agent: Efficient, Secure, and Easy-to-Use. Simplify log monitoring & analysis.
2.2K
The Watchlog Agent Docker image provides a quick, consistent way to deploy the Watchlog Agent for collecting and sending logs and metrics to Watchlog. This guide covers pulling the image, configuring the agent, and running it with the proper runtime options to monitor system and container metrics.
integration.json file.The Watchlog Agent uses file-based configuration via integration.json. All integrations are configured in this single file, making it easy to manage multiple services and instances.
The easiest way to configure the agent is by mounting an integration.json file. This allows you to easily manage multiple integrations and update configurations without modifying Docker commands.
Create a file named integration.json with your integrations:
[
{
"service": "postgresql",
"monitor": false,
"host": "127.0.0.1",
"port": "5432",
"username": "postgres",
"password": "your_password",
"database": ["mydb"]
},
{
"service": "postgresql",
"monitor": false,
"host": "127.0.0.1",
"port": "5433",
"username": "postgres",
"password": "your_password",
"database": ["anotherdb"]
},
{
"service": "mysql",
"monitor": false,
"host": "127.0.0.1",
"port": "3306",
"username": "root",
"password": "your_password",
"database": ["mydb"]
},
{
"service": "redis",
"monitor": false,
"host": "127.0.0.1",
"port": "6379",
"password": ""
},
{
"service": "mongodb",
"monitor": false,
"host": "127.0.0.1",
"port": "27017",
"username": "",
"password": ""
},
{
"service": "docker",
"monitor": false
},
{
"service": "gitlab",
"monitor": false,
"baseUrl": "https://gitlab.com",
"token": "your_token",
"projects": ["project-id-1", "project-id-2"],
"monitorLogs": true,
"metrics": {
"pipelines": true,
"jobs": true,
"runners": true,
"mrs": true,
"deployments": true
}
},
{
"service": "nginx",
"monitor": true,
"accessLog": "/var/log/nginx/access.log"
}
]docker run -d \
--name watchlog-agent \
--network host \
-v /path/to/your/integration.json:/app/app/config/integration.json \
-e WATCHLOG_APIKEY="your_api_key" \
-e WATCHLOG_SERVER="https://your.watchlog.server" \
watchlog/agent:latest# Create volume
docker volume create watchlog-agent-config
Copy your integration.json to the volume (or create it directly)
docker run --rm -v watchlog-agent-config:/data -v /path/to/your/integration.json:/source/integration.json alpine cp /source/integration.json /data/integration.json
Run container
docker run -d
--name watchlog-agent
--network host
-v watchlog-agent-config:/app/app/config
-e WATCHLOG_APIKEY="your_api_key"
-e WATCHLOG_SERVER="https://your.watchlog.server"
watchlog/agent:latest
Only two environment variables are required:
WATCHLOG_APIKEY: Your Watchlog API key. (required)WATCHLOG_SERVER: URL of your Watchlog server (e.g. https://log.watchlog.io). (required)UUID (optional): Override the default host identifier.Note: All integrations are configured in the integration.json file. You do not need to set any additional environment variables for integrations.
The Watchlog Agent can monitor log files from other containers using Docker volumes. Create a log-watchlist.json file in the same directory as your integration.json:
[
{
"name": "app-logs",
"path": "/shared-logs/app.log",
"service": "application",
"format": "auto"
},
{
"name": "nginx-access",
"path": "/shared-logs/nginx/access.log",
"service": "nginx",
"format": "auto"
}
]To access logs from other containers, you need to mount a shared volume. Here are two common approaches:
Create a shared volume and mount it to both containers:
# Create a shared volume for logs
docker volume create shared-logs
Run your application container with the shared volume
docker run -d
--name my-app
-v shared-logs:/app/logs
my-app-image
Run watchlog-agent with the same shared volume
docker run -d
--name watchlog-agent
--network host
-v /path/to/integration.json:/app/app/config/integration.json
-v /path/to/log-watchlist.json:/app/app/config/log-watchlist.json
-v shared-logs:/shared-logs
-e WATCHLOG_APIKEY="your_api_key"
-e WATCHLOG_SERVER="https://your.watchlog.server"
watchlog/agent:latest
In your log-watchlist.json, use paths relative to the mounted volume (e.g., /shared-logs/app.log).
If your application writes logs to the host filesystem, you can bind mount them:
# Run your application container (logs written to host)
docker run -d \
--name my-app \
-v /var/log/my-app:/app/logs \
my-app-image
Run watchlog-agent with access to host logs
docker run -d
--name watchlog-agent
--network host
-v /path/to/integration.json:/app/app/config/integration.json
-v /path/to/log-watchlist.json:/app/app/config/log-watchlist.json
-v /var/log/my-app:/host-logs
-e WATCHLOG_APIKEY="your_api_key"
-e WATCHLOG_SERVER="https://your.watchlog.server"
watchlog/agent:latest
In your log-watchlist.json, use paths relative to the mounted directory (e.g., /host-logs/app.log).
"format": "auto" - Automatically detect log format (nginx, pm2, redis, mysql, docker, postgresql, mongodb)"format": "custom" - Use a custom regex pattern:
{
"name": "custom-logs",
"path": "/shared-logs/custom.log",
"service": "custom",
"format": "custom",
"pattern": "^(?<date>\\d{4}-\\d{2}-\\d{2}) \\[(?<level>\\w+)\\] (?<message>.*)$"
}You can still use the environment variable LOG_WATCHLIST_JSON if the file is not found:
-e LOG_WATCHLIST_JSON='[{"name":"app-logs","path":"/shared-logs/app.log","service":"application","format":"auto"}]'The Watchlog Agent supports monitoring multiple instances of the same service type. Simply add multiple entries with the same service name in your integration.json file.
Monitor multiple PostgreSQL databases on different ports:
[
{
"service": "postgresql",
"monitor": true,
"host": "127.0.0.1",
"port": "5432",
"username": "postgres",
"password": "pass",
"database": ["db1", "db2"]
},
{
"service": "postgresql",
"monitor": true,
"host": "127.0.0.1",
"port": "5433",
"username": "postgres",
"password": "pass",
"database": ["db3"]
}
][
{
"service": "redis",
"monitor": true,
"host": "127.0.0.1",
"port": "6379",
"password": ""
},
{
"service": "redis",
"monitor": true,
"host": "127.0.0.1",
"port": "6380",
"password": "redis_password"
}
][
{
"service": "mysql",
"monitor": true,
"host": "127.0.0.1",
"port": "3306",
"username": "root",
"password": "pass",
"database": ["db1"]
},
{
"service": "mysql",
"monitor": true,
"host": "127.0.0.1",
"port": "3307",
"username": "root",
"password": "pass",
"database": ["db2", "db3"]
}
]Important: Each integration is automatically identified by a unique ID based on host:port combination. Make sure each instance has a unique host/port combination.
docker pull watchlog/agent:latestdocker run -d \
--name watchlog-agent \
--network host \
-v /path/to/integration.json:/app/app/config/integration.json \
-e WATCHLOG_APIKEY="your_api_key" \
-e WATCHLOG_SERVER="https://your.watchlog.server" \
watchlog/agent:latestdocker logs -f watchlog-agentWhen running in Docker, you may need to use --network host to access services on the host machine, or use host.docker.internal as the host address in your configuration.
For Mac/Windows: Use host.docker.internal as the host in your integration.json
For Linux: Use --network host and 127.0.0.1 or localhost as the host
If you encounter any issues, please check the official docs or reach out via [email protected].
Content type
Image
Digest
sha256:2bbf8665f…
Size
71.2 MB
Last updated
11 months ago
docker pull watchlog/agent