Grafana is het observability platform voor monitoring, dashboards en alerting in ASD-PMA.
| Eigenschap |
Waarde |
| Poort |
9200 |
| Container |
asd-grafana |
| Data Source |
Loki, Prometheus |
| Health endpoint |
/api/health |
| Categorie |
Monitoring |
| Classificatie |
Core |
flowchart TB
subgraph Grafana Stack
GRAFANA[asd-grafana<br/>:9200]
LOKI[asd-loki<br/>:9214]
PROMTAIL[Promtail]
end
subgraph Data Sources
PROM[Prometheus]
INFLUX[InfluxDB]
POSTGRES[(PostgreSQL)]
end
subgraph Log Sources
DOCKER[Docker Logs]
APP[Application Logs]
SYSTEM[System Logs]
end
subgraph Alerts
EMAIL[Email]
MM[Mattermost]
WEBHOOK[Webhooks]
end
GRAFANA --> LOKI
GRAFANA --> PROM
GRAFANA --> INFLUX
GRAFANA --> POSTGRES
PROMTAIL --> LOKI
DOCKER --> PROMTAIL
APP --> PROMTAIL
SYSTEM --> PROMTAIL
GRAFANA --> EMAIL
GRAFANA --> MM
GRAFANA --> WEBHOOK
| Dashboard |
Beschrijving |
| System Overview |
CPU, Memory, Disk, Network |
| Docker Containers |
Container metrics per service |
| Application Logs |
Log aggregatie per service |
| n8n Workflows |
Workflow execution metrics |
| Request Metrics |
HTTP requests en latency |
| Source |
Type |
Gebruik |
| Loki |
Logs |
Alle container logs |
| Prometheus |
Metrics |
System en app metrics |
| PostgreSQL |
Database |
Custom queries |
| JSON API |
Externe data |
Service status checks |
| Alert |
Conditie |
Actie |
| High CPU |
CPU > 90% 5min |
Mattermost |
| Low Disk |
Disk < 10% |
Email + Mattermost |
| Container Down |
Container stopped |
Mattermost |
| Error Rate |
Errors > 10/min |
Mattermost |
# Dashboard configuratie voorbeeld
panels:
- title: "CPU Usage"
type: timeseries
datasource: Prometheus
query: "100 - (avg(rate(node_cpu_seconds_total{mode='idle'}[5m])) * 100)"
- title: "Memory Usage"
type: gauge
datasource: Prometheus
query: "(node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes) / node_memory_MemTotal_bytes * 100"
# Alle error logs
{container=~".+"} |= "error"
# Specifieke service logs
{container="asd-redmine"} | json | level="error"
# Rate van errors per minuut
rate({container=~".+"} |= "error" [1m])
Grafana ondersteunt native OAuth2 via Authentik.
sso:
type: grafana
redirect_path: /login/generic_oauth
# Automatische SSO configuratie
just sso-add grafana
# Valideer configuratie
just sso-check grafana
# Test OAuth flow
just sso-test grafana
# Grafana OAuth settings
GF_AUTH_GENERIC_OAUTH_ENABLED=true
GF_AUTH_GENERIC_OAUTH_NAME=Authentik
GF_AUTH_GENERIC_OAUTH_CLIENT_ID=grafana
GF_AUTH_GENERIC_OAUTH_CLIENT_SECRET=<secret>
GF_AUTH_GENERIC_OAUTH_AUTH_URL=http://IP:9101/application/o/authorize/
GF_AUTH_GENERIC_OAUTH_TOKEN_URL=http://asd-authentik:9000/application/o/token/
GF_AUTH_GENERIC_OAUTH_API_URL=http://asd-authentik:9000/application/o/userinfo/
GF_AUTH_GENERIC_OAUTH_SCOPES=openid profile email
¶ Command Reference
¶ Lifecycle Commands
# Start Grafana stack
just start grafana
# Stop Grafana
just stop grafana
# Status bekijken
just status grafana
# Logs bekijken
just logs grafana -f
# Restart
just restart grafana
¶ Management Commands
# Service info met credentials
just info grafana
# Health check
just health grafana
# Backup maken (dashboards + config)
just backup grafana
# Restore van backup
just restore grafana
¶ Dashboard Commands
# Export alle dashboards
just grafana-export-dashboards
# Import dashboard
just grafana-import-dashboard DASHBOARD.json
# Provisioning reload
just grafana-reload-provisioning
Grafana biedt een REST API voor dashboard en data management.
# Via API Key
curl -H "Authorization: Bearer YOUR_API_KEY" \
"http://localhost:9200/api/dashboards/home"
# Via Basic Auth
curl -u "admin:password" \
"http://localhost:9200/api/dashboards/home"
| Endpoint |
Beschrijving |
/api/dashboards |
Dashboard CRUD |
/api/datasources |
Data sources |
/api/alerts |
Alert management |
/api/annotations |
Annotations |
/api/search |
Search dashboards |
# Lijst dashboards
curl -s -H "Authorization: Bearer $GRAFANA_TOKEN" \
"http://localhost:9200/api/search?type=dash-db" | jq '.[] | {title, uid}'
# Dashboard ophalen
curl -s -H "Authorization: Bearer $GRAFANA_TOKEN" \
"http://localhost:9200/api/dashboards/uid/DASHBOARD_UID" | jq .
# Create alert rule
curl -X POST -H "Authorization: Bearer $GRAFANA_TOKEN" \
-H "Content-Type: application/json" \
-d '{"title": "High CPU", "condition": "A", ...}' \
"http://localhost:9200/api/v1/provisioning/alert-rules"
Grafana is geconfigureerd met Loki als primaire log data source.
# Basis query
{container="asd-n8n"}
# Filter op level
{container="asd-n8n"} | json | level="error"
# Zoek specifieke tekst
{container=~"asd-.*"} |= "connection refused"
# Metrics van logs
rate({container="asd-n8n"} | json | level="error" [5m])
# Top 10 error messages
topk(10, sum by (msg) (count_over_time({container="asd-n8n"} | json | level="error" [1h])))
- Open Grafana > Explore
- Selecteer Loki als data source
- Gebruik LogQL voor queries
- Switch tussen Logs en Metrics view
| Variable |
Beschrijving |
Default |
GF_SECURITY_ADMIN_PASSWORD |
Admin password |
Generated |
GF_SERVER_ROOT_URL |
Public URL |
http://localhost:9200 |
GF_INSTALL_PLUGINS |
Plugins installeren |
- |
GF_LOG_MODE |
Log mode |
console file |
| Volume |
Pad |
Inhoud |
grafana_data |
/var/lib/grafana |
Dashboards, users |
grafana_provisioning |
/etc/grafana/provisioning |
Config files |
grafana_logs |
/var/log/grafana |
Logfiles |
- Variabelen gebruiken voor herbruikbare dashboards
- Folders voor organisatie per team/service
- Annotations voor events en deploys
- Links tussen gerelateerde dashboards
- Contact Points configureren (Mattermost, Email)
- Notification Policies voor routing
- Silences voor maintenance windows
- Alert Groups voor gerelateerde alerts