This project demonstrates how to set up a centralized logging system using Docker, Loki, Grafana, and Promtail.
- Loki: A horizontally-scalable, highly-available, multi-tenant log aggregation system inspired by Prometheus.
- Grafana: An open-source platform for monitoring and observability. It's used here to visualize logs stored in Loki.
- Promtail: An agent that ships the contents of local logs to Loki.
-
Prerequisites:
- Docker
- Docker Compose
-
Configuration:
docker-compose.yml: Defines the services (Loki, Promtail, Grafana) and their configurations.loki-config.yml: Configuration file for Loki.promtail-config.yml: Configuration file for Promtail, specifying how to scrape logs and send them to Loki.logs: folder for logs.
-
Running the Stack:
docker-compose up -d
-
Access Grafana:
- Open your browser and go to
http://localhost:3000 - Default credentials:
- Username:
admin - Password:
admin
- Username:
- Change the password when prompted.
- Open your browser and go to
-
Add Loki as a Data Source in Grafana:
- Go to
Configuration>Data Sources>Add data source. - Select
Loki. - Set the URL to
http://loki:3100. - Click
Save & Test.
- Go to
-
Explore Logs:
- Go to
Explorein Grafana. - Select
Lokias the data source. - You can now query and visualize logs from your Docker containers.
- Go to
-
View Logs:
- Open your browser and go to
http://localhost:3100. - You can view logs directly from the Loki web interface.
- Open your browser and go to
-
Stop the Stack:
docker-compose down



