Grafana Loki is a log aggregation tool inspired by Prometheus, or simply put Prometheus for logs. In this tutorial I’m going to show you how to install and configure the Loki logging driver in Docker.
Prerequisites
- Docker
- Grafana Loki
Solution
Step 1. Install the Loki Docker plugin.
docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions
Step 2. Verify installation.
docker plugin ls
Output:
ID NAME DESCRIPTION ENABLED
1e87f2ea1a08 loki:latest Loki Logging Driver true
Step 3. Configure the Loki logging driver to be default for all Docker containers. Open or create the /etc/docker/daemon.json
file first.
Step 4. Add the following code block:
{
"log-driver": "loki",
"log-opts": {
"loki-url": "https://<user_id>:<password>@<loki_endpoint>/loki/api/v1/push",
"loki-batch-size": "400"
}
}
Step 5. Restart the Docker service.
systemctl restart docker
Conclusion
Official Docker Driver Client from Grafana Loki documentation. On a side note, follow our official channel on Telegram.