Add n8n workflows 01-08 (with upgrades), 14-16; planning docs; .gitignore
This commit is contained in:
383
n8n-workflows/15-n8n-health-monitor.json
Normal file
383
n8n-workflows/15-n8n-health-monitor.json
Normal file
@@ -0,0 +1,383 @@
|
||||
{
|
||||
"name": "n8n Self-Health Monitor",
|
||||
"active": true,
|
||||
"isArchived": false,
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"rule": {
|
||||
"interval": [
|
||||
{
|
||||
"field": "minutes",
|
||||
"minutesInterval": 15
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"id": "dabcb0ae-d513-410e-b779-4570df5c4a35",
|
||||
"name": "Every 15 Minutes",
|
||||
"type": "n8n-nodes-base.scheduleTrigger",
|
||||
"typeVersion": 1.2,
|
||||
"position": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "GET",
|
||||
"url": "http://10.5.1.6:5678/api/v1/executions",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "X-N8N-API-KEY",
|
||||
"value": "={{ $env.N8N_API_KEY }}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendQuery": true,
|
||||
"queryParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "status",
|
||||
"value": "error"
|
||||
},
|
||||
{
|
||||
"name": "includeData",
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"name": "limit",
|
||||
"value": "50"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "806d75e9-b95a-499a-b997-a7f7dc046775",
|
||||
"name": "Fetch Failed Executions",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
224,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const data = $input.first().json;\nconst executions = data.data || [];\nconst oneHourAgo = Date.now() - (60 * 60 * 1000);\n\n// Filter to failures in the past hour\nconst recent = executions.filter(e => {\n const ts = new Date(e.startedAt || e.stoppedAt || 0).getTime();\n return ts >= oneHourAgo;\n});\n\n// Group by workflow name + error message for dedup key\nconst failures = recent.map(e => ({\n executionId: e.id,\n workflowId: e.workflowId,\n workflowName: e.workflowData?.name || `Workflow ${e.workflowId}`,\n startedAt: e.startedAt,\n stoppedAt: e.stoppedAt,\n errorMessage: e.data?.resultData?.error?.message || 'Unknown error'\n}));\n\n// Deduplicate by workflowName (report once per workflow per check)\nconst seen = new Set();\nconst unique = failures.filter(f => {\n if (seen.has(f.workflowName)) return false;\n seen.add(f.workflowName);\n return true;\n});\n\nreturn [{ json: { hasFailures: unique.length > 0, count: unique.length, failures: unique } }];"
|
||||
},
|
||||
"id": "f5d47910-5047-4c4f-aa84-a6907aa38551",
|
||||
"name": "Filter Recent Failures",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
448,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"conditions": {
|
||||
"options": {
|
||||
"caseSensitive": true,
|
||||
"leftValue": "",
|
||||
"typeValidation": "strict"
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"id": "a76d10a7-1313-467e-9648-471b296229a3",
|
||||
"leftValue": "={{ $json.hasFailures }}",
|
||||
"rightValue": true,
|
||||
"operator": {
|
||||
"type": "boolean",
|
||||
"operation": "equal"
|
||||
}
|
||||
}
|
||||
],
|
||||
"combinator": "and"
|
||||
}
|
||||
},
|
||||
"id": "7c298433-ab89-435e-8955-73da6b986f46",
|
||||
"name": "Has Failures?",
|
||||
"type": "n8n-nodes-base.if",
|
||||
"typeVersion": 2.2,
|
||||
"position": [
|
||||
672,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const d = $input.first().json;\n// Fingerprint = sorted workflow names joined \u2014 stable across retriggers\nconst fingerprint = (d.failures || [])\n .map(f => f.workflowName)\n .sort()\n .join('|') || 'unknown';\nreturn [{ json: { ...d, fingerprint } }];"
|
||||
},
|
||||
"id": "d3609d45-ba9f-41d3-a9bd-8c558a719f10",
|
||||
"name": "Build Fingerprint",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
896,
|
||||
-120
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "executeQuery",
|
||||
"query": "SELECT fingerprint, last_seen FROM n8n_health_dedup WHERE fingerprint = '{{ $json.fingerprint }}' AND last_seen > NOW() - INTERVAL '1 hour' LIMIT 1;",
|
||||
"options": {}
|
||||
},
|
||||
"id": "15a3dd71-bc5b-4396-9534-63518e097438",
|
||||
"name": "Lookup Dedup",
|
||||
"type": "n8n-nodes-base.postgres",
|
||||
"typeVersion": 2.5,
|
||||
"position": [
|
||||
1120,
|
||||
-120
|
||||
],
|
||||
"credentials": {
|
||||
"postgres": {
|
||||
"id": "n9svoXemqSZoNNUB",
|
||||
"name": "Postgres account"
|
||||
}
|
||||
},
|
||||
"continueOnFail": true
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const alertData = $('Build Fingerprint').first().json;\nconst rows = $input.all().filter(r => r.json && r.json.fingerprint);\nconst alreadyNotified = rows.length > 0;\nreturn [{ json: { ...alertData, alreadyNotified, shouldNotify: !alreadyNotified } }];"
|
||||
},
|
||||
"id": "a92590e3-7044-4ba3-9b39-f6a9457c5fbe",
|
||||
"name": "Check Already Notified",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1344,
|
||||
-120
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"conditions": {
|
||||
"options": {
|
||||
"caseSensitive": true,
|
||||
"leftValue": "",
|
||||
"typeValidation": "strict"
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"id": "b1e77af5-6875-47dd-97af-8e13958a7217",
|
||||
"leftValue": "={{ $json.shouldNotify }}",
|
||||
"rightValue": true,
|
||||
"operator": {
|
||||
"type": "boolean",
|
||||
"operation": "equal"
|
||||
}
|
||||
}
|
||||
],
|
||||
"combinator": "and"
|
||||
}
|
||||
},
|
||||
"id": "39ac0eaf-73ce-4fe1-9c4b-d09ac920291d",
|
||||
"name": "Should Notify?",
|
||||
"type": "n8n-nodes-base.if",
|
||||
"typeVersion": 2.2,
|
||||
"position": [
|
||||
1568,
|
||||
-120
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "executeQuery",
|
||||
"query": "INSERT INTO n8n_health_dedup (fingerprint, last_seen, workflow_names) VALUES ('{{ $json.fingerprint }}', NOW(), '{{ $json.failures.map(f => f.workflowName).join(\", \") }}') ON CONFLICT (fingerprint) DO UPDATE SET last_seen = NOW(), workflow_names = EXCLUDED.workflow_names;",
|
||||
"options": {}
|
||||
},
|
||||
"id": "0c3be155-0c3a-4354-b863-73a3f5bbf598",
|
||||
"name": "Upsert Dedup Record",
|
||||
"type": "n8n-nodes-base.postgres",
|
||||
"typeVersion": 2.5,
|
||||
"position": [
|
||||
1792,
|
||||
-120
|
||||
],
|
||||
"credentials": {
|
||||
"postgres": {
|
||||
"id": "n9svoXemqSZoNNUB",
|
||||
"name": "Postgres account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const d = $('Build Fingerprint').first().json;\nconst lines = (d.failures || []).map(f =>\n ` \u2022 ${f.workflowName}\\n ${f.errorMessage.substring(0, 120)}`\n);\nconst body = `${d.count} workflow${d.count !== 1 ? 's' : ''} failed in the past hour:\\n\\n${lines.join('\\n')}\\n\\nhttps://n8n.paccoco.com`;\nreturn [{ json: { title: `\u26a0\ufe0f n8n: ${d.count} Workflow Failure${d.count !== 1 ? 's' : ''}`, message: body, priority: 7 } }];"
|
||||
},
|
||||
"id": "1c6b42bf-a38e-47b6-82ac-50c43ee9e583",
|
||||
"name": "Format Notification",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
2016,
|
||||
-120
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"message": "={{ $json.message }}",
|
||||
"additionalFields": {
|
||||
"priority": "={{ $json.priority }}",
|
||||
"title": "={{ $json.title }}"
|
||||
},
|
||||
"options": {
|
||||
"contentType": "text/plain"
|
||||
}
|
||||
},
|
||||
"id": "09435c2f-9044-432a-8ca8-dd3ce3262c76",
|
||||
"name": "Push to Gotify",
|
||||
"type": "n8n-nodes-base.gotify",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
2240,
|
||||
-120
|
||||
],
|
||||
"credentials": {
|
||||
"gotifyApi": {
|
||||
"id": "SETUP_REQUIRED",
|
||||
"name": "n8n Health"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"Every 15 Minutes": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Fetch Failed Executions",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Fetch Failed Executions": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Filter Recent Failures",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Filter Recent Failures": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Has Failures?",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Has Failures?": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Build Fingerprint",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
[]
|
||||
]
|
||||
},
|
||||
"Build Fingerprint": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Lookup Dedup",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Lookup Dedup": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Check Already Notified",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Check Already Notified": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Should Notify?",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Should Notify?": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Upsert Dedup Record",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
[]
|
||||
]
|
||||
},
|
||||
"Upsert Dedup Record": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Format Notification",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Format Notification": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Push to Gotify",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"executionOrder": "v1",
|
||||
"binaryMode": "separate"
|
||||
},
|
||||
"staticData": null,
|
||||
"meta": null,
|
||||
"pinData": {},
|
||||
"tags": [
|
||||
{
|
||||
"name": "monitoring"
|
||||
},
|
||||
{
|
||||
"name": "scheduled"
|
||||
},
|
||||
{
|
||||
"name": "n8n"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user