Caution
Grafana Agent has reached End-of-Life (EOL) on November 1, 2025. Agent is no longer receiving vendor support and will no longer receive security or bug fixes. Current users of Agent Static mode, Agent Flow mode, and Agent Operator should proceed with migrating to Grafana Alloy. If you have already migrated to Alloy, no further action is required. Read more about why we recommend migrating to Grafana Alloy.
Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
loki.source.docker
loki.source.docker reads log entries from Docker containers and forwards them
to other loki.* components. Each component can read from a single Docker
daemon.
Multiple loki.source.docker components can be specified by giving them
different labels.
Usage
loki.source.docker "LABEL" {
host = HOST
targets = TARGET_LIST
forward_to = RECEIVER_LIST
}Arguments
The component starts a new reader for each of the given targets and fans out
log entries to the list of receivers passed in forward_to.
loki.source.file supports the following arguments:
Blocks
The loki.source.docker component doesn’t support any inner blocks and is
configured fully through arguments.
Exported fields
loki.source.docker does not export any fields.
Component health
loki.source.docker is only reported as unhealthy if given an invalid
configuration.
Debug information
loki.source.docker exposes some debug information per target:
- Whether the target is ready to tail entries.
- The labels associated with the target.
- The most recent time a log line was read.
Debug metrics
loki_source_docker_target_entries_total(gauge): Total number of successful entries sent to the Docker target.loki_source_docker_target_parsing_errors_total(gauge): Total number of parsing errors while receiving Docker messages.
Example
This example collects log entries from the files specified in the targets
argument and forwards them to a loki.write component to be written to Loki.
discovery.docker "linux" {
host = "unix:///var/run/docker.sock"
}
loki.source.docker "default" {
host = "unix:///var/run/docker.sock"
targets = discovery.docker.linux.targets
forward_to = [loki.write.local.receiver]
}
loki.write "local" {
endpoint {
url = "loki:3100/api/v1/push"
}
}


