Log collection stack using Grafana Alloy, Loki, and Grafana.
Host logs / Docker logs
│
▼
Grafana Alloy (collector) :12345
│
▼
Loki (log store) :3100
│
▼
Grafana (dashboard) :3000
| Service | Image | Port |
|---|---|---|
| Alloy | grafana/alloy:latest |
12345 (debug UI) |
| Loki | grafana/loki |
3100 |
| Grafana | grafana/grafana:latest |
3000 |
- System logs —
/var/log/*.log - Docker container logs — via Docker socket, labeled with
containerandimage - App logs (optional, commented out) —
/app/logs/*.logwith JSON level extraction
./deploy-grafana-loki.sh./deploy-alloy.shEach script prompts for confirmation before running docker compose up -d.
| File | Purpose |
|---|---|
alloy/config.alloy |
Alloy pipeline — sources, relabeling, Loki endpoint |
loki/loki-config.yaml |
Loki storage and retention settings |
grafana/docker-compose.yaml |
Grafana env vars and volume mounts |
Set in alloy/config.alloy at the loki.write block:
loki.write "default" {
endpoint {
url = "http://<LOKI_IP>:3100/loki/api/v1/push"
}
}Update <LOKI_IP> to match your Loki host.
| Field | Value |
|---|---|
| URL | http://localhost:3000 |
| Username | admin |
| Password | Grafana-123 |