n8n Grafana Prometheus Metrics Workflow Observability
I use Grafana and Prometheus for n8n monitoring because they’re free, open-source, and give me more visibility than paid solutions. Datadog is convenient but costs scale with metric volume. Grafana scales with your willingness to configure it.
Prometheus scrapes metrics from n8n at regular intervals. Grafana visualizes them in dashboards and triggers alerts when thresholds are crossed. Together they provide complete observability without per-metric pricing.
The setup takes about 45 minutes. After that, you have real-time dashboards, historical trend analysis, and automated alerts running 24/7.
Installing Prometheus
Prometheus is a time-series database that collects and stores metrics. Install it on the same network as your n8n instance:
`bash
Download Prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.50.0/prometheus-2.50.0.linux-amd64.tar.gz
tar xzf prometheus-*.tar.gz
cd prometheus-*/
Start Prometheus
./prometheus –config.file=prometheus.yml –storage.tsdb.path=/var/lib/prometheus
`
The default configuration scrapes Prometheus itself every 15 seconds. Configure it to scrape n8n metrics too:
`yaml
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
– job_name: ‘prometheus’
static_configs:
– targets: [‘localhost:9090’]
– job_name: ‘n8n’
static_configs:
– targets: [‘localhost:9100’]
metrics_path: /metrics
`
This configuration tells Prometheus to scrape metrics from port 9100, where the n8n exporter listens. The scrape interval determines how frequently metrics are collected.
For production deployments, run Prometheus as a systemd service:
`ini
[Unit]
Description=Prometheus Monitoring
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/opt/prometheus/prometheus \
–config.file=/etc/prometheus/prometheus.yml \
–storage.tsdb.path=/var/lib/prometheus \
–storage.tsdb.retention.time=30d \
–web.enable-lifecycle
[Install]
WantedBy=multi-user.target
`
The 30-day retention keeps a month of historical data. Enough for trend analysis and capacity planning. The web.enable-lifecycle flag allows hot reloading of configuration without restarting.
Installing the n8n Exporter
The n8n Exporter is a lightweight service that exposes n8n metrics in Prometheus format. It connects to the n8n API and translates internal metrics into Prometheus-compatible time series.
`bash
Clone the exporter
git clone https://github.com/bwp/geeky-beast-n8n-exporter.git
cd geeky-beast-n8n-exporter
Install dependencies
npm install
Configure
cp .env.example .env
Edit .env with your n8n URL and API key
`
`env
N8N_URL=http://localhost:5678
N8N_API_KEY=your-n8n-api-key
PROMETHEUS_PORT=9100
SCRAPE_INTERVAL=30
`
The exporter queries n8n’s API for workflow execution statistics, active workflow counts, and resource utilization. It exposes these as Prometheus metrics on port 9100.
Start the exporter:
`bash
npm start
`
Verify it’s working:
`bash
curl http://localhost:9100/metrics
`
You should see Prometheus-format metric definitions:
`
HELP n8n_workflow_executions_total Total workflow executions
TYPE n8n_workflow_executions_total counter
n8n_workflow_executions_total{workflow=”email_sync”,status=”success”} 1247
n8n_workflow_executions_total{workflow=”email_sync”,status=”failed”} 23
HELP n8n_workflow_duration_avg Average workflow execution duration in milliseconds
TYPE n8n_workflow_duration_avg gauge
n8n_workflow_duration_avg{workflow=”email_sync”} 2340.5
`
These metrics are what Prometheus scrapes and stores. The workflow and status labels let you filter and aggregate data in Grafana.
Installing Grafana
Grafana provides visualization and alerting on top of Prometheus data:
`bash
Ubuntu/Debian
apt-get install -y apt-transport-https software-properties-common
wget -q -O – https://packages.grafana.com/gpg.key | apt-key add –
echo “deb https://packages.grafana.com/oss/deb stable main” > /etc/apt/sources.list.d/grafana.list
apt-get update
apt-get install grafana
Start Grafana
systemctl start grafana-server
systemctl enable grafana-server
`
Access Grafana at http://localhost:3000. Default credentials are admin/admin. Change the password on first login.
Add Prometheus as a data source:
1. Navigate to Configuration → Data Sources
2. Click Add data source
3. Select Prometheus
4. Set URL to http://localhost:9090
5. Click Save and Test
The data source connection confirms Prometheus is reachable. Grafana can now query metrics.
Building the n8n Dashboard
Create a new dashboard:
1. Navigate to Dashboards → New dashboard
2. Click Add visualization
3. Select Prometheus as the data source
Add these panels:
Panel 1: Workflow Execution Count
Query:
`promql
sum(rate(n8n_workflow_executions_total[5m])) by (workflow)
`
This shows executions per minute, grouped by workflow. The 5-minute rate window smooths out spikes while catching sustained increases.
Visualization: Time series graph with stacked bars. Color by workflow name. Legend shows total count.
Panel 2: Execution Success Rate
Query:
`promql
sum(rate(n8n_workflow_executions_total{status=”success”}[5m])) / sum(rate(n8n_workflow_executions_total[5m])) * 100
`
This calculates the percentage of successful executions. Alert when this drops below 95%.
Visualization: Gauge panel with thresholds. Green > 99%, Yellow 95-99%, Red < 95%.
Panel 3: Average Execution Duration
Query:
`promql
n8n_workflow_duration_avg
`
Show average duration per workflow. Add a trend line to detect gradual increases.
Visualization: Time series with transparent shaded area. Add annotation lines for SLA thresholds.
Panel 4: Active Workflow Count
Query:
`promql
n8n_active_workflows
`
Track the number of workflows currently active. Drops indicate configuration issues or workflow deletions.
Visualization: Stat panel with large number display. Color code by count.
Panel 5: Error Rate by Workflow
Query:
`promql
topk(10, sum(rate(n8n_workflow_executions_total{status=”failed”}[1h])) by (workflow))
`
Show the 10 workflows with the most failures in the last hour. Sort descending.
Visualization: Bar chart. Click a bar to drill into that workflow’s details.
Panel 6: Resource Utilization
Query Prometheus node exporter metrics:
`promql
node_cpu_seconds_total{instance=”n8n-exporter:9100″, mode!=”idle”}
node_memory_MemAvailable_bytes{instance=”n8n-exporter:9100″} / node_memory_MemTotal_bytes{instance=”n8n-exporter:9100″} * 100
`
Track CPU and memory usage on the n8n host. Correlate resource spikes with workflow execution increases.
Visualization: Dual-axis graph. Left axis for CPU percentage. Right axis for memory percentage.
Save the dashboard as n8n-production-overview. Share it with your team and pin it to your operations screen.
Configuring Alerts
Grafana alerts trigger notifications when metrics cross thresholds:
1. Navigate to the panel you want to monitor
2. Click the panel menu (three dots)
3. Select Alert → Create alert
Configure alert rules:
Alert 1: High Error Rate
Condition: Success rate < 95% for 5 minutes Notification: Send to Slack #ops-alerts Severity: Critical
PromQL:
`promql
sum(rate(n8n_workflow_executions_total{status=”success”}[5m])) / sum(rate(n8n_workflow_executions_total[5m])) * 100 < 95
`
Alert 2: Execution Duration Spike
Condition: Average duration > 10 seconds for 10 minutes
Notification: Send to Slack #ops-alerts
Severity: Warning
PromQL:
`promql
n8n_workflow_duration_avg > 10000
`
Alert 3: Workflow Count Drop
Condition: Active workflows < expected count for 15 minutes Notification: Send to email on-call Severity: Critical
PromQL:
`promql
n8n_active_workflows < 20
`
Grafana evaluates alert conditions at the scrape interval (15 seconds by default). Evaluation frequency affects how quickly alerts fire. More frequent evaluation catches issues faster but increases load on Prometheus.
For production, set up notification channels:
1. Slack webhook for real-time alerts
2. Email for detailed reports
3. PagerDuty integration for critical incidents
Configure each channel in Grafana’s notification settings. Assign severity levels to determine which channels receive which alerts.
Log Correlation
Correlate Grafana metrics with n8n execution logs for complete debugging visibility. When a dashboard shows an anomaly, click through to the corresponding log entries.
Set up Loki (Log Aggregation) alongside Prometheus and Grafana:
`bash
Add Loki to prometheus.yml
static_configs:
– targets: [‘localhost:3100’]
`
Configure n8n to ship logs to Loki using the Promtail agent:
`yaml
promtail-config.yaml
clients:
– url: http://localhost:3100/loki/api/v1/push
scrape_configs:
– job_name: n8n-logs
static_configs:
– targets:
– localhost
labels:
job: n8n
__path__: /var/log/n8n/*.log
`
Grafana displays metrics and logs in the same dashboard. Toggle between views or display them side by side. When execution duration spikes, switch to the log view to see which workflows caused the delay.
Performance Tuning
Prometheus memory usage grows with metric cardinality. High-cardinality metrics (unique labels per data point) consume more memory.
Control cardinality by:
1. Limiting label values — don’t use user IDs or request IDs as labels
2. Aggregating metrics at scrape time — sum individual workflow metrics into totals
3. Dropping low-value metrics — exclude debug or verbose metrics from production
`yaml
prometheus.yml – relabel configs to drop unwanted metrics
scrape_configs:
– job_name: ‘n8n’
metrics_path: /metrics
metric_relabel_configs:
– source_labels: [__name__]
regex: ‘n8n_debug_.*’
action: drop
`
This configuration drops all metrics starting with n8n_debug_. Keep debug metrics during development. Remove them in production to reduce storage requirements.
Grafana dashboard performance improves with query optimization:
1. Use rate() and irate() instead of raw counters
2. Limit time ranges in queries — don’t query 30 days of data for a 5-minute view
3. Use recording rules for complex calculations — pre-compute aggregations
Recording rules:
`yaml
prometheus.yml
rule_files:
– n8n-rules.yml
n8n-rules.yml
groups:
– name: n8n-aggregations
rules:
– record: n8n:executions:rate5m
expr: sum(rate(n8n_workflow_executions_total[5m])) by (workflow)
– record: n8n:error_rate:ratio5m
expr: >
sum(rate(n8n_workflow_executions_total{status=”failed”}[5m])) by (workflow)
/
sum(rate(n8n_workflow_executions_total[5m])) by (workflow)
`
Recording rules pre-compute expensive queries. Grafana reads the pre-computed results instantly instead of calculating them on demand.
Connecting to Your Monitoring
The n8n Datadog monitoring guide covers the managed alternative. Datadog requires less setup but costs increase with metric volume. Grafana/Prometheus is free but requires infrastructure management. Choose based on team capacity and budget.
The n8n workflow logging guide complements metrics with structured logs. Metrics show what’s happening. Logs show why. Both are necessary for complete observability.
The n8n DevOps nodes guide shows how to send alerts from n8n workflows. Integrate Grafana alerts with Slack or PagerDuty using these nodes for multi-channel notification.
Action Card: One-Command Stack Deploy
Deploy Prometheus + Grafana + n8n Exporter with Docker Compose:
`yaml
version: ‘3.8’
services:
prometheus:
image: prom/prometheus:latest
volumes:
– ./prometheus.yml:/etc/prometheus/prometheus.yml
– prometheus-data:/var/lib/prometheus
ports:
– “9090:9090”
grafana:
image: grafana/grafana:latest
ports:
– “3000:3000”
volumes:
– grafana-data:/var/lib/grafana
n8n-exporter:
image: geekybeast/n8n-exporter:latest
environment:
– N8N_URL=http://n8n:5678
– PROMETHEUS_PORT=9100
ports:
– “9100:9100”
volumes:
prometheus-data:
grafana-data:
`
Start with docker-compose up -d. Add Prometheus as a Grafana data source. Import the n8n dashboard JSON. You’re monitoring in 10 minutes.
