"Draait het?" is niet genoeg. In productie wil je weten: hoeveel workflows faalden vandaag? Welke API calls zijn traag? Gaat het geheugengebruik omhoog? Deze gids leert je hoe je een compleet monitoring-systeem opzet voor je n8n instance — van health checks tot Grafana dashboards.
Wat je leert:
- n8n health endpoints: /healthz en /metrics
- Prometheus metrics configureren en scrapen
- Grafana dashboard bouwen voor n8n
- Logging: niveaus, structuur en best practices
- Alerting instellen: wanneer en hoe
- Workflow-level monitoring met n8n zelf
De 3 Pijlers van Observability
📊
Metrics
Getallen over tijd: success rate, execution duur, geheugengebruik, queue size
Tool: Prometheus
📝
Logs
Gedetailleerde events: errors, warnings, node outputs, HTTP responses
Tool: n8n Logging + ELK
🔗
Traces
End-to-end request flow: van trigger tot laatste node, inclusief externe calls
Tool: OpenTelemetry
n8n Health Endpoints
n8n biedt drie ingebouwde endpoints voor monitoring:
| Endpoint | Wat het checkt | Response | Gebruik |
|---|---|---|---|
| /healthz | Is n8n bereikbaar? | 200 OK (geen DB check) | Load balancer health check |
| /healthz/readiness | Is n8n klaar voor traffic? | 200 OK (inclusief DB check) | Kubernetes readiness probe |
| /metrics | Prometheus-formatted metrics | Metrics in text format | Prometheus scraping |
Prometheus Metrics Instellen
Prometheus is de industriestandaard voor metrics collection. n8n kan metrics exposen die Prometheus scraped.
# n8n Environment Variables voor Metrics
# Activeer de metrics endpoint
N8N_METRICS=true
# Metrics endpoint configuratie
N8N_METRICS_PREFIX=n8n_
N8N_METRICS_INCLUDE_DEFAULT_METRICS=true
N8N_METRICS_INCLUDE_CACHE_METRICS=true
N8N_METRICS_INCLUDE_MESSAGE_EVENT_BUS_METRICS=true
N8N_METRICS_INCLUDE_WORKFLOW_ID_LABEL=true
# Docker Compose voorbeeld:
services:
n8n:
image: n8nio/n8n
environment:
- N8N_METRICS=true
ports:
- "5678:5678"
prometheus:
image: prom/prometheus
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
grafana:
image: grafana/grafana
ports:
- "3000:3000"
Prometheus Configuratie
# prometheus.yml
scrape_configs:
- job_name: 'n8n'
scrape_interval: 30s
static_configs:
- targets: ['n8n:5678']
metrics_path: '/metrics'
# Beschikbare n8n metrics:
# n8n_workflow_execution_total{status="success|error"}
# n8n_workflow_execution_duration_seconds
# n8n_active_workflows_total
# n8n_queue_depth (als queue mode actief is)
# Plus standaard Node.js metrics:
# process_heap_bytes, process_cpu_seconds_total, etc.
Grafana Dashboard Bouwen
Met de metrics in Prometheus bouw je een overzichtelijk dashboard:
Essentiële Grafana Queries
// PromQL queries voor je n8n Grafana dashboard
// 1. Success Rate (percentage)
100 * (
sum(rate(n8n_workflow_execution_total{status="success"}[5m]))
/
sum(rate(n8n_workflow_execution_total[5m]))
)
// 2. Executies per minuut
sum(rate(n8n_workflow_execution_total[5m])) * 60
// 3. Gemiddelde executie duur
histogram_quantile(0.95,
rate(n8n_workflow_execution_duration_seconds_bucket[5m])
)
// 4. Failed executions per workflow
sum by (workflow_name) (
increase(n8n_workflow_execution_total{status="error"}[24h])
)
// 5. Geheugengebruik
process_resident_memory_bytes{job="n8n"} / 1024 / 1024
// → Geeft MB geheugengebruik
// 6. Queue depth (als queue mode actief)
n8n_queue_depth
Logging Configureren
n8n heeft ingebouwde logging met configureerbare niveaus en output formats.
# Logging Environment Variables # Log niveau: error, warn, info, debug N8N_LOG_LEVEL=info # Output format: "text" (leesbaar) of "json" (parseable) N8N_LOG_OUTPUT=console # Execution data opslaan EXECUTIONS_DATA_SAVE_ON_ERROR=all EXECUTIONS_DATA_SAVE_ON_SUCCESS=all EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=true # Execution data pruning (voorkomt database groei) EXECUTIONS_DATA_MAX_AGE=168 # 7 dagen (in uren) EXECUTIONS_DATA_PRUNE=true EXECUTIONS_DATA_PRUNE_MAX_COUNT=50000
Gestructureerde Logging Best Practices
| Practice | Waarom | Implementatie |
|---|---|---|
| Correlation IDs | Volg een executie door het hele systeem | executionId in elke log regel |
| Node type loggen | Consistenter dan node namen (die wijzigen) | n8n-nodes-base.httpRequest |
| Meerdere IDs | Cross-reference mogelijkheden | executionId + workflowId + sessionId |
| Dupliceer in metadata | Makkelijker zoeken in log aggregators | Workflow naam in zowel message als labels |
Alerting: Wanneer en Hoe
Goede alerts zijn actionable. Elke alert moet een duidelijke actie triggeren — anders is het ruis.
| Alert | Trigger | Urgentie | Actie |
|---|---|---|---|
| n8n Down | /healthz geeft geen 200 voor 2 min | P1 — Direct | Restart container, check logs |
| Success rate < 95% | 5-min rolling average onder drempel | P2 — Urgent | Check failing workflows, API status |
| Geheugen > 80% | process_heap_bytes te hoog | P3 — Monitor | Identificeer memory leaks, restart |
| Queue groeit | Queue depth stijgt 5+ min | P3 — Monitor | Scale workers, check bottleneck |
Workflow-Level Monitoring met n8n Zelf
Naast infrastructure monitoring kun je n8n zelf gebruiken om je workflows te monitoren — een "watchdog" workflow.
// Dagelijkse Health Report Workflow
Schedule Trigger (08:00, maandag-vrijdag)
↓
HTTP Request → n8n API
GET /api/v1/executions?status=error&limit=100
Header: X-N8N-API-KEY: {{ $env.N8N_API_KEY }}
↓
HTTP Request → n8n API (successes)
GET /api/v1/executions?status=success&limit=1
// We willen alleen de count weten
↓
Code Node (genereer rapport)
const errors = $('Error Executions').all();
const totalSuccess = $('Success Count').first().json.count;
const totalErrors = errors.length;
const total = totalSuccess + totalErrors;
const successRate = total > 0
? ((totalSuccess / total) * 100).toFixed(1)
: 0;
// Groepeer fouten per workflow
const errorsByWorkflow = {};
errors.forEach(e => {
const name = e.json.workflowData?.name || 'Onbekend';
errorsByWorkflow[name] = (errorsByWorkflow[name] || 0) + 1;
});
// Top 5 failende workflows
const topFailing = Object.entries(errorsByWorkflow)
.sort((a, b) => b[1] - a[1])
.slice(0, 5)
.map(([name, count]) => ` ${name}: ${count}x`)
.join('\n');
return {
text: `📊 *Dagelijks n8n Report*\n\n` +
`Totaal: ${total} executies\n` +
`✅ Geslaagd: ${totalSuccess}\n` +
`❌ Gefaald: ${totalErrors}\n` +
`📈 Success rate: ${successRate}%\n\n` +
(totalErrors > 0
? `*Top failende workflows:*\n${topFailing}`
: '🎉 Geen fouten!')
};
↓
Slack Node (#automation-report)
OpenTelemetry voor Distributed Tracing
Voor complexe setups met meerdere n8n instances of externe microservices is OpenTelemetry (OTel) de standaard voor distributed tracing.
# OpenTelemetry configuratie voor n8n
# Docker Compose met OTel Collector
services:
n8n:
image: n8nio/n8n
environment:
- N8N_DIAGNOSTICS_ENABLED=true
# OTel export configuratie
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
- OTEL_SERVICE_NAME=n8n-production
otel-collector:
image: otel/opentelemetry-collector
volumes:
- ./otel-config.yaml:/etc/otel/config.yaml
ports:
- "4317:4317" # OTLP gRPC
- "4318:4318" # OTLP HTTP
jaeger:
image: jaegertracing/all-in-one
ports:
- "16686:16686" # Jaeger UI
# Met tracing kun je:
# - Een executie volgen van trigger tot output
# - Zien welke externe API calls de meeste tijd kosten
# - Bottlenecks identificeren in complexe workflows
# - Cross-service correlaties leggen
Productie Monitoring Checklist
Monitoring Maturity Model
Level 1: Basis
Health endpoint monitoren + Error Workflow met Slack alert
Level 2: Metrics
Prometheus + Grafana dashboard met success rate, duration, queue depth
Level 3: Alerting
Tiered alerting (P1-P3), on-call rotatie, runbooks per alert
Level 4: Observability
Distributed tracing, structured logging, correlation IDs, SLOs