Container Monitoring
Loggator automatically discovers and monitors Docker containers based on labels, providing real-time insights into their logs and health.
How It Works
Section titled “How It Works”Loggator connects to the Docker socket and:
- Discovers containers with the monitoring label
- Streams logs in real-time (both stdout and stderr)
- Indexes logs into Meilisearch
- Monitors container lifecycle events
Container Discovery
Section titled “Container Discovery”Automatic Discovery
Section titled “Automatic Discovery”When Loggator starts:
- Scans all running containers
- Checks for the monitoring label
- Begins streaming logs immediately
Dynamic Monitoring
Section titled “Dynamic Monitoring”Loggator listens for Docker events:
- Container started: Monitoring begins automatically
- Container stopped: Monitoring stops gracefully
- Container recreated: Reconnects to new instance
No manual configuration required!
Label-Based Security
Section titled “Label-Based Security”Only containers with the specified label are accessed:
services: my-app: labels: - "loggator.enable=true" # This container will be monitoredThis prevents:
- Unauthorized access to containers
- Accidental monitoring of sensitive services
- Resource waste on irrelevant logs
Log Streaming
Section titled “Log Streaming”Dual Streams
Section titled “Dual Streams”Loggator captures both output streams:
stdout (Standard Output)
Section titled “stdout (Standard Output)”- Normal application logs
- Info messages
- Debug output
- Access logs
stderr (Standard Error)
Section titled “stderr (Standard Error)”- Error messages
- Warnings
- Exceptions
- Stack traces
Stream Processing
Section titled “Stream Processing”For each log line:
- Timestamp Extraction: Parses Docker timestamps
- Stream Tagging: Labels as stdout or stderr
- Metadata Addition: Container name, ID, labels
- Batch Buffering: Groups for efficient indexing
- Indexing: Sends to Meilisearch
Real-Time Performance
Section titled “Real-Time Performance”- Latency: 5-10 seconds from log to index
- Throughput: ~1000 logs/second
- Batch Size: 100 logs or 5-second timeout
Container Information
Section titled “Container Information”For each monitored container, Loggator tracks:
Basic Info
Section titled “Basic Info”- Name: Container name (without leading
/) - ID: Full container ID
- Short ID: First 12 characters
- Image: Docker image and tag
Status
Section titled “Status”- State: running, stopped, paused, restarting
- Status: Human-readable status message
- Exit Code: If stopped
- Health: Container health check status
Timestamps
Section titled “Timestamps”- Created: When container was created
- Started: When last started
- Finished: When stopped (if applicable)
Network
Section titled “Network”- Ports: Port mappings
- Networks: Connected networks
- IP Addresses: Per network
Resources
Section titled “Resources”- CPU: Current CPU usage (if available)
- Memory: Current memory usage (if available)
- Labels: All Docker labels
Container Lifecycle
Section titled “Container Lifecycle”Starting a Container
Section titled “Starting a Container”docker run -d \ --label loggator.enable=true \ --name my-app \ nginx:latestLoggator:
- Detects
startevent - Inspects container for label
- Begins log streaming
- Adds to monitored list
Stopping a Container
Section titled “Stopping a Container”docker stop my-appLoggator:
- Detects
stopevent - Closes log stream gracefully
- Removes from active monitoring
- Historical logs remain searchable
Restarting a Container
Section titled “Restarting a Container”docker restart my-appLoggator:
- Detects
stopevent → closes old stream - Detects
startevent → opens new stream - Continues logging seamlessly
Removing a Container
Section titled “Removing a Container”docker rm my-appLoggator:
- Detects
destroyevent - Removes from monitoring
- Logs remain in Meilisearch
- Can still be searched by name
Health Monitoring
Section titled “Health Monitoring”Container Health Checks
Section titled “Container Health Checks”If your container has a health check:
services: api: image: myapi:latest labels: - "loggator.enable=true" healthcheck: test: ["CMD", "curl", "-f", "http://localhost/health"] interval: 30s timeout: 10s retries: 3Loggator shows health status:
- healthy: Green indicator
- unhealthy: Red indicator
- starting: Yellow indicator
Log-Based Health Analysis
Section titled “Log-Based Health Analysis”The AI assistant can analyze container health:
Query: "Is my api container healthy?"Analyzes:
- Error rate in recent logs
- Warning patterns
- Critical messages
- Crash indicators
Container List View
Section titled “Container List View”The container list shows:
Visual Indicators
Section titled “Visual Indicators”- Running: Green badge with “running” text
- Stopped: Red badge with “exited” text
- Status: Full Docker status string
Sort Options
Section titled “Sort Options”Sort containers by:
- Name (alphabetical)
- Status (running first)
- Created (newest first)
- Log count (highest first)
Filter Options
Section titled “Filter Options”Filter containers by:
- Status (running/stopped)
- Name (search)
- Image (specific image)
- Label (additional labels)
API Access
Section titled “API Access”Get container information programmatically:
List All Containers
Section titled “List All Containers”curl http://localhost:3000/api/containersGet Container Details
Section titled “Get Container Details”curl http://localhost:3000/api/containers/my-appContainer Logs
Section titled “Container Logs”curl "http://localhost:3000/api/logs/search?container=my-app&limit=100"See Containers API for full documentation.
Best Practices
Section titled “Best Practices”1. Label Consistently
Section titled “1. Label Consistently”Use the same label across environments:
labels: - "loggator.enable=true"2. Don’t Monitor Everything
Section titled “2. Don’t Monitor Everything”Skip containers with:
- High log volume (databases)
- Sensitive data (auth services)
- Temporary purpose (build containers)
3. Organize with Additional Labels
Section titled “3. Organize with Additional Labels”Use extra labels for organization:
labels: - "loggator.enable=true" - "app=myapp" - "tier=backend" - "environment=production"4. Monitor Container Health
Section titled “4. Monitor Container Health”Add health checks to your containers:
healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:3000/health || exit 1"] interval: 30s5. Use Meaningful Names
Section titled “5. Use Meaningful Names”Clear names help in logs:
❌ container_1, app_web_1
✅ myapp-api, myapp-web
Troubleshooting
Section titled “Troubleshooting”Container not appearing
Section titled “Container not appearing”Check:
# Container is runningdocker ps | grep my-app
# Has correct labeldocker inspect my-app | grep loggator.enable
# Loggator can access Docker socketdocker logs loggator | grep "Docker"No logs from container
Section titled “No logs from container”Verify:
# Container is producing logsdocker logs my-app
# Logs go to stdout/stderr (not files)# Check application log configurationContainer shows but no logs
Section titled “Container shows but no logs”Causes:
- Container hasn’t logged yet
- Logs go to files instead of stdout/stderr
- Meilisearch indexing issue
Solutions:
- Trigger some application activity
- Configure app to log to stdout/stderr
- Check Meilisearch:
curl http://localhost:7700/health
Duplicate logs
Section titled “Duplicate logs”Cause: Container was restarted while Loggator was running
Solution: This is normal. Both old and new logs are preserved.
High resource usage
Section titled “High resource usage”If monitoring many containers:
- Filter selectively: Only label necessary containers
- Increase resources: More RAM for Loggator
- Batch settings: Increase batch size (requires code change)
- Log retention: Delete old logs periodically
Advanced Configuration
Section titled “Advanced Configuration”Custom Label Filter
Section titled “Custom Label Filter”Change the label Loggator looks for:
loggator: environment: DOCKER_LABEL_FILTER: app.monitor=productionMultiple Loggator Instances
Section titled “Multiple Loggator Instances”Run separate instances for different purposes:
services: loggator-prod: environment: DOCKER_LABEL_FILTER: environment=production ports: - "3000:3000"
loggator-dev: environment: DOCKER_LABEL_FILTER: environment=development ports: - "3001:3000"Docker Socket Alternatives
Section titled “Docker Socket Alternatives”For Docker Swarm or remote Docker:
loggator: environment: DOCKER_HOST: tcp://remote-docker:2376 DOCKER_CERT_PATH: /certs DOCKER_TLS_VERIFY: 1 volumes: - ./certs:/certs:roSecurity Considerations
Section titled “Security Considerations”Read-Only Socket
Section titled “Read-Only Socket”Always use read-only mount:
volumes: - /var/run/docker.sock:/var/run/docker.sock:roLabel-Based Access Control
Section titled “Label-Based Access Control”Only labeled containers are accessed:
- Prevents information leakage
- Reduces attack surface
- Supports multi-tenant setups
Sensitive Containers
Section titled “Sensitive Containers”Avoid labeling containers with:
- Secrets or credentials
- Personal information (PII)
- Financial data
- Authentication tokens
Next Steps
Section titled “Next Steps”- Docker Setup - Configure container labels
- Dashboard - Monitor containers visually
- API Reference - Integrate container data