Alternative Docker log capture
If you are having trouble with the Docker socket method of scraping logs, or for security reasons can’t use that method, the folks at Grafana have provided a log driver for Docker that can deliver logs to Loki directly, thus bypassing Promtail entirely. It requires downloading a special Loki log driver for Docker and updating the docker-compose.yml
file so that it includes driver-specific configuration. To download and install the driver, run the following command:
% docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions
The plugin installation command will download the latest driver and install it with an alias of loki
(so that we can access it easily from Docker Compose), with wide-open permissions. To confirm the installation, run the following command:
% docker plugin ls ID NAME DESCRIPTION ENABLED 692bec0b6ade loki:latest Loki Logging Driver true
If you get true
as output, then your plugin loaded...