A generalized monitoring stack to be installed on individual servers that we want to monitor.
Consists of:
- cAdvisor: Exports docker container metrics for consumption by Prometheus
- Node-Exporter: Exports server system metrics for consumption by Prometheus
- Grafana Alloy: Ships application and container logs to Loki (replaces Promtail)
Supports both Docker Compose and Docker Swarm deployments. In Swarm mode, Alloy extracts stable service-level labels (swarm_service, stack) so dashboards survive container rescheduling.
Clone the repo:
git clone https://github.com/Giveth/giveth-monitor.git
Copy .env.template to .env and fill in the values:
cp .env.template .env && nano .env
Grafana Alloy is the log collector that ships logs from host machines to the Loki server.
The configuration lives in alloy-config.alloy and uses Alloy's River syntax. It collects:
- Caddy logs from
/var/giveth/logs/caddy/*(static file scraping) - Docker container logs via the Docker socket (automatic discovery)
| Label | Source | Available in |
|---|---|---|
container |
Container name | Compose + Swarm |
logstream |
stdout / stderr | Compose + Swarm |
job |
logging_jobname container label |
Compose + Swarm |
swarm_service |
com.docker.swarm.service.name |
Swarm only |
stack |
com.docker.stack.namespace |
Swarm only |
swarm_task |
com.docker.swarm.task.name |
Swarm only |
node_id |
com.docker.swarm.node.id |
Swarm only |
service |
Short service name (without stack prefix) | Swarm only |
compose_service |
com.docker.compose.service |
Compose only |
compose_project |
com.docker.compose.project |
Compose only |
- Swarm deployments: Use
{swarm_service="mystack_web"}or{service="web"}in LogQL queries. Create dashboard variables withlabel_values(swarm_service). - Compose deployments: Use
{compose_service="web"}or{container="web-1"}. - Avoid filtering by
containername in Swarm — it changes on every reschedule.
All credentials are injected via sys.env() in the Alloy config. Required variables in .env:
LOKI_URL— Loki push endpoint (e.g.https://loki.mydomain.com)INSTANCE— Tenant ID, unique per monitored instance (e.g.staging)LOKIUSER— Loki basic auth usernameLOKIPASS— Loki basic auth password
- Modify
docker-compose.ymlto add volume mounts for additional log directories - Update
alloy-config.alloyto add morelocal.file_match+loki.source.fileblocks for additional static log paths - Ensure
.envhas been configured — Alloy depends on a Loki URL and credentials
docker-compose up -d
docker stack deploy -c docker-compose.yml giveth-monitor
docker-compose down
docker-compose up -d servicename
Alloy includes a built-in web UI for inspecting component health, discovered targets, and pipeline status:
http://<host>:12345
If the host runs Caddy or another reverse proxy, open the necessary ports for the monitoring stack. Run 01-allow-ports.sh which restricts access to a trusted IP:
- 8080 — cAdvisor metrics
- 12345 — Alloy UI / API
- 9100 — Node-Exporter metrics
The previous promtail-config.yml is kept for reference. To migrate an existing deployment:
- Update
.env: replacePROMTAIL_VERSIONwithALLOY_VERSION=v1.13.1 - Pull the new images:
docker-compose pull - Restart:
docker-compose up -d - Verify at
http://<host>:12345that Alloy is discovering containers - Update firewall rules: run
01-allow-ports.sh(port changed from 9080 to 12345) - If the Loki Docker log driver was previously installed, remove it to avoid double-ingestion:
This disables/removes the plugin and cleans up
sudo bash 02-remove-loki-docker-driver.sh/etc/docker/daemon.json(with backup and confirmation).