Docker logs
Collect logs from Docker
Alias
This component was previously called the docker source. Make sure to update your
Vector configuration to accommodate the name change:
[sources.my_docker_logs_source]
+type = "docker_logs"
-type = "docker"
Requirements
docker. Please ensure the running user is part of the docker group.Warnings
exclude_containers.Configuration
Example configurations
{
"sources": {
"my_source_id": {
"type": "docker_logs"
}
}
}[sources.my_source_id]
type = "docker_logs"
sources:
my_source_id:
type: docker_logs
{
"sources": {
"my_source_id": {
"type": "docker_logs",
"auto_partial_merge": true,
"docker_host": "http://localhost:2375",
"exclude_containers": [
"exclude_"
],
"include_containers": [
"include_"
],
"include_images": [
"httpd"
],
"include_labels": [
"org.opencontainers.image.vendor=Vector"
],
"partial_event_marker_field": "_partial",
"retry_backoff_secs": 2
}
}
}[sources.my_source_id]
type = "docker_logs"
auto_partial_merge = true
docker_host = "http://localhost:2375"
exclude_containers = [ "exclude_" ]
include_containers = [ "include_" ]
include_images = [ "httpd" ]
include_labels = [ "org.opencontainers.image.vendor=Vector" ]
partial_event_marker_field = "_partial"
retry_backoff_secs = 2
sources:
my_source_id:
type: docker_logs
auto_partial_merge: true
docker_host: http://localhost:2375
exclude_containers:
- exclude_
include_containers:
- include_
include_images:
- httpd
include_labels:
- org.opencontainers.image.vendor=Vector
partial_event_marker_field: _partial
retry_backoff_secs: 2
docker_host
optional string literalDocker host to connect to.
Use an HTTPS URL to enable TLS encryption.
If absent, the DOCKER_HOST environment variable is used. If DOCKER_HOST is also absent,
the default Docker local socket (/var/run/docker.sock on Unix platforms,
//./pipe/docker_engine on Windows) is used.
exclude_containers
optional [string]A list of container IDs or names of containers to exclude from log collection.
Matching is prefix first, so specifying a value of foo would match any container named foo as well as any
container whose name started with foo. This applies equally whether matching container IDs or names.
By default, the source collects logs for all containers. If exclude_containers is configured, any
container that matches a configured exclusion is excluded even if it is also included with
include_containers, so care should be taken when using prefix matches as they cannot be overridden by a
corresponding entry in include_containers, for example, excluding foo by attempting to include foo-specific-id.
This can be used in conjunction with include_containers.
host_key
optional string literalOverrides the name of the log field used to add the current hostname to each event.
By default, the global log_schema.host_key option is used.
include_containers
optional [string]A list of container IDs or names of containers to include in log collection.
Matching is prefix first, so specifying a value of foo would match any container named foo as well as any
container whose name started with foo. This applies equally whether matching container IDs or names.
By default, the source collects logs for all containers. If include_containers is configured, only
containers that match a configured inclusion and are also not excluded get matched.
This can be used in conjunction with exclude_containers.
include_images
optional [string]A list of image names to match against.
If not provided, all images are included.
include_labels
optional [string]A list of container object labels to match against when filtering running containers.
Labels should follow the syntax described in the Docker object labels documentation.
multiline
optional objectMultiline aggregation configuration.
If not specified, multiline aggregation is disabled.
multiline.condition_pattern
required string literalRegular expression pattern that is used to determine whether or not more lines should be read.
This setting must be configured in conjunction with mode.
multiline.mode
required string literal enumAggregation mode.
This setting must be configured in conjunction with condition_pattern.
| Option | Description |
|---|---|
continue_past | All consecutive lines matching this pattern, plus one additional line, are included in the group. This is useful in cases where a log message ends with a continuation marker, such as a backslash, indicating that the following line is part of the same message. |
continue_through | All consecutive lines matching this pattern are included in the group. The first line (the line that matched the start pattern) does not need to match the This is useful in cases such as a Java stack trace, where some indicator in the line (such as a leading whitespace) indicates that it is an extension of the proceeding line. |
halt_before | All consecutive lines not matching this pattern are included in the group. This is useful where a log line contains a marker indicating that it begins a new message. |
halt_with | All consecutive lines, up to and including the first line matching this pattern, are included in the group. This is useful where a log line ends with a termination marker, such as a semicolon. |
multiline.start_pattern
required string literalmultiline.timeout_ms
required uintThe maximum amount of time to wait for the next additional line, in milliseconds.
Once this timeout is reached, the buffered message is guaranteed to be flushed, even if incomplete.
partial_event_marker_field
optional string literalOverrides the name of the log field used to mark an event as partial.
If auto_partial_merge is disabled, partial events are emitted with a log field, set by this
configuration value, indicating that the event is not complete.
_partialretry_backoff_secs
optional uint2(seconds)tls
optional objectConfiguration of TLS when connecting to the Docker daemon.
Only relevant when connecting to Docker with an HTTPS URL.
If not configured, the environment variable DOCKER_CERT_PATH is used. If DOCKER_CERT_PATH is absent, then DOCKER_CONFIG is used. If both environment variables are absent, the certificates in ~/.docker/ are read.
tls.ca_file
required string literaltls.crt_file
required string literaltls.key_file
required string literalEnvironment variables
DOCKER_CERT_PATH
common optional string literalPath to look for TLS certificates when tls configuration is absent.
Vector will use:
$DOCKER_CERT_PATH/ca.pem: CA certificate.$DOCKER_CERT_PATH/cert.pem: TLS certificate.$DOCKER_CERT_PATH/key.pem: TLS key.
DOCKER_CONFIG
common optional string literaltls configuration and DOCKER_CERT_PATH are absent.DOCKER_HOST
common optional string literaldocker_host configuration is absent.Outputs
<component_id>
Output Types
Logs
Warning
Log
Fields
2020-10-10T17:07:36.452332Z9b6247364a03715ebfcee040evil_ptolemynostalgic_stallmangethostname command.my-host.localubuntu:latestbusyboxtimberio/vector:latest-alpine{
"mylabel": "myvalue"
}Started GET / for 127.0.0.1 at 2012-03-10 14:28:14 +0100dockerstdoutstderr2020-10-10T17:07:36.452332ZTelemetry
Metrics
linkcomponent_discarded_events_total
counterfilter transform, or false if due to an error.component_errors_total
countercomponent_received_bytes_total
countercomponent_received_event_bytes_total
countercomponent_received_events_count
histogramA histogram of the number of events passed in each internal batch in Vector’s internal topology.
Note that this is separate than sink-level batching. It is mostly useful for low level debugging performance issues in Vector due to small internal batches.
component_received_events_total
countercomponent_sent_event_bytes_total
countercomponent_sent_events_total
countercontainer_processed_events_total
countercontainers_unwatched_total
countercontainers_watched_total
countersource_lag_time_seconds
histogramExamples
Dummy Logs
Given this event... ```json
{
"stream": "stdout",
"message": "150.75.72.205 - - [03/Oct/2020:16:11:29 +0000] "HEAD /initiatives HTTP/1.1" 504 117"
}
```sources:
my_source_id:
type: docker_logs
include_images:
- mingrammer/flog
[sources.my_source_id]
type = "docker_logs"
include_images = [ "mingrammer/flog" ]
{
"sources": {
"my_source_id": {
"type": "docker_logs",
"include_images": [
"mingrammer/flog"
]
}
}
}{
"container_created_at": "2020-10-03T16:11:29.443232Z",
"container_id": "fecc98177eca7fb75a2b2186c418bf9a0cd3a05a1169f2e2293bf8987a9d96ab",
"container_name": "flog",
"host": "my-host.local",
"image": "mingrammer/flog",
"message": "150.75.72.205 - - [03/Oct/2020:16:11:29 +0000] \"HEAD /initiatives HTTP/1.1\" 504 117",
"source_type": "docker",
"stream": "stdout"
}How it works
Context
docker_logs source augments events with helpful
context keys.Merging Split Messages
auto_partial_merge option. Furthermore, you can adjust the marker
that we use to determine if an event is partial via the
partial_event_marker_field option.