docker_logs source collects logs from Docker containers by connecting to the Docker daemon. It automatically discovers running containers and captures their stdout/stderr streams.
Configuration
Parameters
Docker host to connect to. Defaults to
DOCKER_HOST environment variable, or local socket.Container IDs or names to include. Prefix matching is used.
Container IDs or names to exclude. Takes precedence over
include_containers.Docker labels to filter containers by.
Image names to filter containers by.
Field name for the hostname. Defaults to global
log_schema.host_key.Automatically merge partial log lines.Docker splits long log lines into multiple chunks. When enabled, these are automatically reassembled.
Field name to mark partial events (when
auto_partial_merge is false).Time to wait before retrying after errors (in seconds).
Multiline aggregation configuration.
TLS configuration for HTTPS Docker hosts.
Output Schema
The Docker logs source produces log events with the following fields:| Field | Type | Description |
|---|---|---|
message | string | The log line content |
container_id | string | Full container ID |
container_name | string | Container name |
image | string | Container image name |
container_created_at | timestamp | When the container was created |
stream | string | ”stdout” or “stderr” |
label.* | string | Container labels (if any) |
host | string | Hostname where Vector is running |
timestamp | timestamp | Log timestamp from Docker |
source_type | string | Always “docker_logs” |
Examples
Basic Docker Logs Collection
Filter by Container Names
Filter by Labels
Filter by Image Names
Remote Docker Host with TLS
Java Stack Traces
Disable Partial Merge
How It Works
Container Discovery
The source connects to the Docker daemon and:- Lists all currently running containers
- Applies filtering based on
include_*andexclude_*settings - Starts streaming logs from matched containers
- Watches for container start/stop events
- Automatically begins/ends log collection as containers start/stop
Log Streaming
For each container, the source:- Opens a persistent connection to the Docker daemon’s logs API
- Receives stdout and stderr streams
- Parses Docker’s log format (timestamp + stream + message)
- Enriches events with container metadata
- Handles log rotation and container restarts
Partial Message Handling
Docker splits log lines longer than 16KB into multiple partial messages. Whenauto_partial_merge is enabled:
- Partial messages are buffered
- Complete messages are reassembled
- Only complete messages are emitted
partial_event_marker_field set to true.
Container Metadata
The source enriches each log event with:- Container ID (full and short)
- Container name
- Image name and tag
- Container creation timestamp
- All container labels
- Stream type (stdout/stderr)
Performance
- Minimal overhead compared to file-based collection
- Scales to hundreds of containers on a single host
- Memory usage scales with the number of watched containers
- Partial message buffering adds minimal latency
Best Practices
- Use label-based filtering for dynamic container environments
- Mount the Docker socket as read-only:
-v /var/run/docker.sock:/var/run/docker.sock:ro - Run Vector in a container for consistent Docker API access
- Enable multiline aggregation for stack traces and multi-line logs
- Configure appropriate retry backoff for Docker daemon restarts
- Monitor Vector’s internal metrics for container discovery issues
- Use specific image filters to reduce overhead in large deployments
- Test exclusion rules to ensure they don’t inadvertently exclude important containers
Docker Compose Example
Kubernetes Considerations
In Kubernetes, consider using thekubernetes_logs source instead, which:
- Reads logs from Kubernetes API
- Includes pod and namespace metadata
- Handles Kubernetes-specific log formats
- Integrates with Kubernetes RBAC
docker_logs can still be useful for:
- Development environments
- Non-Kubernetes Docker deployments
- Specific container filtering requirements
Troubleshooting
Permission Denied
Ensure Vector has access to the Docker socket:Missing Containers
Check filtering rules:High Memory Usage
Reduce the number of watched containers:- Use more specific include/exclude filters
- Filter by labels or images
- Disable
auto_partial_mergeif not needed