A production-friendly Docker Compose monitoring stack with Grafana and Loki. This repository provides secure-by-default configuration, persistent storage, and automated Grafana datasource provisioning.
This stack is designed for quickly deploying log monitoring with minimal manual setup:
- Loki ingests and stores logs on local filesystem storage.
- Grafana provides dashboards and visualization.
- Grafana provisioning automatically registers Loki as a datasource.
- GitHub OAuth controls Grafana access through your GitHub organization.
grafanaservice- Exposed on
http://localhost:3000 - Uses mounted
grafana/grafana.inifor configuration - Uses mounted provisioning directory for datasource auto-loading
- Persists data in Docker volume
grafana_data
- Exposed on
lokiservice- Exposed on
http://localhost:3100 - Uses mounted
loki/config.yml - Persists data in Docker volume
loki_data
- Exposed on
- Shared custom Docker network:
monitoring
monitoring-stack/
├── docker-compose.yml
├── .env.example
├── README.md
├── grafana/
│ ├── grafana.ini
│ └── provisioning/
│ └── datasources/
│ └── datasource.yml
├── loki/
│ └── config.yml
└── scripts/
├── start.sh
└── stop.sh
-
Copy the environment template:
cp .env.example .env
-
Edit
.envwith secure credentials and GitHub OAuth values. -
Start the stack:
./scripts/start.sh
-
Open Grafana:
- URL:
http://localhost:3000
- URL:
-
In GitHub, create an OAuth App.
-
Set:
- Homepage URL: your Grafana URL (for example
https://grafana.example.com) - Authorization callback URL:
<GRAFANA_ROOT_URL>/login/github
- Homepage URL: your Grafana URL (for example
-
Put credentials in
.env:GITHUB_CLIENT_IDGITHUB_CLIENT_SECRET
-
Restrict access with
GITHUB_ALLOWED_ORG. -
Restart Grafana:
docker compose restart grafana
-
Start services:
docker compose up -d
-
Stop services:
docker compose down
-
Check status:
docker compose ps
-
View logs:
docker compose logs -f
GRAFANA_ADMIN_USER=admin
GRAFANA_ADMIN_PASSWORD=change-me
GRAFANA_ROOT_URL=http://localhost:3000
GITHUB_CLIENT_ID=replace-with-client-id
GITHUB_CLIENT_SECRET=replace-with-client-secret
GITHUB_ALLOWED_ORG=your-github-org- Grafana OAuth login fails
- Confirm callback URL is exactly
<GRAFANA_ROOT_URL>/login/github. - Confirm
GITHUB_ALLOWED_ORGmatches your organization.
- Confirm callback URL is exactly
- Datasource not visible in Grafana
- Check provisioning files are mounted:
docker compose exec grafana ls -R /etc/grafana/provisioning - Restart Grafana after provisioning changes.
- Check provisioning files are mounted:
- Containers unhealthy
- Inspect health and logs:
docker compose ps docker compose logs loki grafana
- Inspect health and logs:
- Update
grafana/grafana.inifor server/security/auth settings. - Add dashboards/provisioning under
grafana/provisioning/. - Restart Grafana after config changes.
-
Edit
loki/config.ymlfor retention, limits, and ingestion settings. -
Keep filesystem paths under
/lokialigned with mounted volumeloki_data. -
Restart Loki after config updates:
docker compose restart loki