Skip to content

Commit 2a1d4cf

Browse files
authored
Merge pull request #112 from kossakovsky/worktree-fix-issues-110-111
Workflow execution monitoring, worker scrape fix, runner build fix (release 1.10.0)
2 parents 9b01721 + aef485a commit 2a1d4cf

16 files changed

Lines changed: 784 additions & 29 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ certs/*
2525
# Custom Caddy addons (user configurations)
2626
caddy-addon/*.conf
2727
!caddy-addon/*.example
28+
29+
# Prometheus worker targets (generated by scripts/generate_n8n_workers.sh)
30+
prometheus/targets/*.json
31+
!prometheus/targets/.gitkeep

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
## [Unreleased]
44

5+
## [1.10.0] - 2026-09-02
6+
7+
### Added
8+
- **Monitoring** - The n8n Grafana dashboard now shows whether workflows actually run, not just whether the n8n process is healthy. n8n is started with `N8N_METRICS_INCLUDE_MESSAGE_EVENT_BUS_METRICS`, `N8N_METRICS_INCLUDE_WORKFLOW_ID_LABEL`, `N8N_METRICS_INCLUDE_WORKFLOW_NAME_LABEL` and `N8N_METRICS_INCLUDE_WORKFLOW_INFO`, which expose `n8n_workflow_started/success/failed/cancelled_total` counters labelled per workflow plus id-to-name gauges, and a new "Workflow Executions" section adds three panels: executions by outcome over time, executions per workflow, and time since each active workflow's last successful execution. The last one is backed by Prometheus recording rules in `prometheus/rules/n8n-workflows.yml` that remember the last non-manual success per workflow for 30 days and follow renames. Four Grafana-managed alert rules are provisioned from `grafana/provisioning/alerting/n8n-workflows.yml`: "n8n workflow failed" (a non-manual execution failed in the last 15 minutes - runs from the editor are excluded), "n8n workflow stalled" (an active workflow has had no success for 24 hours), "n8n workflow has no recorded success" (active for 24 hours without ever succeeding since monitoring started - catches workflows that were already broken at upgrade time) and "n8n metrics target down" (Prometheus cannot scrape n8n or a worker). The 24-hour thresholds are global and tunable in that file; provisioned rules are read-only in the UI. Alerts follow Grafana's default notification policy, whose built-in email contact point delivers nothing without SMTP - create a contact point and select it under Alerting > Notification policies. The Prometheus data source now has the fixed uid `Prometheus` that the dashboards and rules reference (#110).
9+
10+
### Fixed
11+
- **Monitoring** - Prometheus never scraped the n8n workers: the `n8n-worker` job targeted a hostname that does not exist (containers are `n8n-worker-1`, `n8n-worker-2`, ...) on the task-broker port 5679 instead of the metrics port 5678. `scripts/generate_n8n_workers.sh` now writes `prometheus/targets/n8n.json` with the n8n main target and one target per worker, read by Prometheus via `file_sd_configs`, so the target list follows `N8N_WORKER_COUNT` automatically. The generator runs on every install and update and removes the file when n8n is deselected, so a monitoring-only install no longer carries a permanently-down `n8n:5678` target. `make doctor` reports a missing or outdated targets file and a failing recording rule (#110).
12+
- **Doctor** - `make doctor` could never report Grafana or Prometheus as down: the check was gated on a profile named after the container, but both belong to the `monitoring` profile. The check now takes the enabling profile explicitly.
13+
- **n8n** - `docker compose build` failed on `n8n/Dockerfile.runner` with `/bin/sh: pnpm: Permission denied` (exit code 126). The upstream `n8nio/runners:stable` image rebuilt on 2026-09-02 ships `pnpm.cjs` without the execute bit (pnpm 11.22.0), so the `pnpm add cheerio axios moment lodash` step could not start even as root. The Dockerfile now restores the bit on the symlink target before running pnpm; the fix is a no-op once upstream republishes a correct image (#111).
14+
515
## [1.9.0] - 2026-08-27
616

717
### Added

CLAUDE.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ This is **Selfhost AI** (repository `selfhost-ai`, formerly `n8n-install`), a Do
3232
- `scripts/06_run_services.sh`: Starts Docker Compose stack
3333
- `scripts/07_final_report.sh`: Post-install credential summary
3434
- `scripts/08_fix_permissions.sh`: Fixes file ownership for non-root access
35-
- `scripts/generate_n8n_workers.sh`: Generates dynamic worker/runner compose file
35+
- `scripts/generate_n8n_workers.sh`: Generates dynamic worker/runner compose file and the Prometheus n8n targets file
3636
- `scripts/generate_ollama_instances.sh`: Generates extra Ollama instances compose file (multi-GPU)
3737
- `scripts/update.sh`: Update orchestrator (syncs with origin and updates images)
3838
- `scripts/update_preview.sh`: Preview available updates without applying (dry-run)
@@ -184,6 +184,15 @@ This project uses [Semantic Versioning](https://semver.org/). When updating `CHA
184184
- No published ports and no Caddy block for extra instances - they are internal (`ollama2:11434`); `caddy-addon/site-*.conf` is the documented extension point
185185
- The generator is invoked unconditionally from `05_configure_services.sh`, which covers install and `make update`, and self-heals a stale file after a hardware-profile switch
186186

187+
### Monitoring (Prometheus + Grafana)
188+
189+
- n8n metrics are enabled in the `x-n8n` anchor: `N8N_METRICS` plus `N8N_METRICS_INCLUDE_MESSAGE_EVENT_BUS_METRICS` / `_WORKFLOW_ID_LABEL` / `_WORKFLOW_NAME_LABEL` / `_WORKFLOW_INFO`. They expose `n8n_workflow_{started,success,failed,cancelled}_total{workflow_id,workflow_name}` and the `n8n_workflow_info` / `n8n_active_workflow_info` id-to-name gauges (leader main only). The alerts and recording rules also use `n8n_workflow_execution_duration_seconds{status,mode,workflow_id}`, which is on by default (`N8N_METRICS_INCLUDE_WORKFLOW_EXECUTION_DURATION`); turning it off silently disables them. Setting `N8N_METRICS_PREFIX` would break every panel and alert
190+
- **In queue mode the workflow counters and the duration histogram are emitted by `n8n` main**, which finalises every top-level execution; workers only report sub-workflow executions, node events and their own process metrics. Panels and rules therefore aggregate across instances (`sum by (...)`) and must not filter on `$instance`
191+
- Scrape targets are not static: `generate_n8n_workers.sh` writes `prometheus/targets/n8n.json` (gitignored) with the `n8n:5678` main target and one `n8n-worker-N:5678` per worker, each group carrying its `job` label, and `prometheus.yml` reads it via `file_sd_configs`. The generator runs unconditionally from `05_configure_services.sh` and removes the file when the n8n profile is inactive, so a monitoring-only install has no n8n targets and no permanently-down alert. Metrics are served on the queue-health port (`QUEUE_HEALTH_CHECK_PORT`, default 5678; 5679 is the task broker)
192+
- `prometheus/rules/*.yml` holds recording rules keyed on `workflow_id` (`n8n:workflow_success:increase5m`, `n8n:workflow_last_success_timestamp_seconds`); names are joined at query time from `n8n_active_workflow_info`, so renames are followed. The whole `prometheus/` directory is bind-mounted read-only to `/etc/prometheus`
193+
- Grafana's datasource, dashboards and alert rules are file-provisioned from `grafana/provisioning/`; contact points and notification policies are not, and no SMTP is configured. The Prometheus datasource has the fixed `uid: Prometheus` that dashboards and alert rules reference - keep them in sync. Use `$__rate_interval`, never a fixed range window, in range queries
194+
- No Alertmanager: alert rules are Grafana-managed (`grafana/provisioning/alerting/n8n-workflows.yml`); a malformed file stops Grafana from starting. `make doctor` checks that Grafana/Prometheus run, that the targets file matches `N8N_WORKER_COUNT` and that Prometheus loaded the `n8n-workflows` rule group without errors
195+
187196
### Caddy Reverse Proxy
188197

189198
- Automatically obtains Let's Encrypt certificates when `LETSENCRYPT_EMAIL` is set

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
- **AI Agents & RAG** — Flowise, Dify, LangChain, vector databases (Qdrant, Weaviate)
2929
- **One Command Install** — Interactive wizard, automatic secrets, zero manual configuration
3030
- **Auto HTTPS** — Caddy reverse proxy with automatic Let's Encrypt certificates
31-
- **Built-in Monitoring** — Grafana + Prometheus stack included
31+
- **Built-in Monitoring** — Grafana + Prometheus stack included, with an n8n dashboard that tracks workflow executions (outcomes, per-workflow volume, time since last success) and ready-made alert rules for failed or stalled workflows
3232
- **Production Ready** — Scalable workers, health checks, proper service dependencies
3333
- **Free & Open Source** — No vendor lock-in, Apache 2.0 license
3434

@@ -239,6 +239,7 @@ After successful installation, your services are up and running! Here's how to g
239239

240240
4. **Check Monitoring (Optional):**
241241
- Visit Grafana (`grafana.yourdomain.com`) to see dashboards monitoring your system's performance (data sourced from Prometheus).
242+
- The **n8n Monitoring** dashboard includes a *Workflow Executions* section, and four alert rules are pre-provisioned: *n8n workflow failed* (non-manual executions only, so testing in the editor does not page), *n8n workflow stalled* (an active workflow with no success for 24 hours), *n8n workflow has no recorded success* (active for 24 hours without ever succeeding since monitoring started) and *n8n metrics target down*. The 24-hour thresholds are global, so workflows that run less than daily will alert; tune them in `grafana/provisioning/alerting/n8n-workflows.yml`. Alerts follow Grafana's default notification policy, whose built-in email contact point delivers nothing without SMTP: create a contact point (Telegram, Slack, Email with `GF_SMTP_*`, ...) under **Alerting → Contact points** and select it in **Alerting → Notification policies**.
242243

243244

244245
## Secure Access with Cloudflare Tunnel (Optional)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.9.0
1+
1.10.0

docker-compose.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ x-n8n: &service-n8n
8282
N8N_LOG_LEVEL: "${N8N_LOG_LEVEL:-info}"
8383
N8N_LOG_OUTPUT: "${N8N_LOG_OUTPUT:-console}"
8484
N8N_METRICS: true
85+
N8N_METRICS_INCLUDE_MESSAGE_EVENT_BUS_METRICS: true
86+
N8N_METRICS_INCLUDE_WORKFLOW_ID_LABEL: true
87+
N8N_METRICS_INCLUDE_WORKFLOW_NAME_LABEL: true
88+
N8N_METRICS_INCLUDE_WORKFLOW_INFO: true
8589
N8N_PAYLOAD_SIZE_MAX: "${N8N_PAYLOAD_SIZE_MAX:-256}"
8690
N8N_PERSONALIZATION_ENABLED: false
8791
N8N_PROXY_HOPS: "${N8N_PROXY_HOPS:-1}"
@@ -795,7 +799,7 @@ services:
795799
profiles: ["monitoring"]
796800
restart: unless-stopped
797801
volumes:
798-
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
802+
- ./prometheus:/etc/prometheus:ro
799803
- prometheus_data:/prometheus
800804
extra_hosts:
801805
- "host.docker.internal:host-gateway"

0 commit comments

Comments
 (0)