From a8eefb63c12035e9d712953733bf2d3a038d8942 Mon Sep 17 00:00:00 2001 From: Roman Buryan Date: Wed, 14 Oct 2026 11:36:41 +0300 Subject: [PATCH] =?UTF-8?q?fix(n8n):=20self-healing=20=E2=80=94=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=B4=D0=B0=D1=87=D0=B8=20=D0=B2=20=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=87=D0=B8=D0=B9=20=D1=80=D0=B5=D0=BF=D0=BE=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B8=D0=B9,=20=D1=83=D1=81=D0=BB=D0=BE?= =?UTF-8?q?=D0=B2=D0=B8=D0=B5=20v2,=20=D0=B2=D0=B5=D1=82=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BB=D0=BE=D0=B6=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infra/n8n/workflows/workflow-current.json | 219 +++++++++++----------- 1 file changed, 110 insertions(+), 109 deletions(-) diff --git a/infra/n8n/workflows/workflow-current.json b/infra/n8n/workflows/workflow-current.json index 74c3701..15ec028 100644 --- a/infra/n8n/workflows/workflow-current.json +++ b/infra/n8n/workflows/workflow-current.json @@ -2,88 +2,76 @@ { "id": "TSqu00NJx2JOrtoN", "name": "Uptime Kuma → Gitea Self-Healing", - "description": null, - "active": true, - "createdAt": "2026-09-11T12:37:51.879Z", - "updatedAt": "2026-09-25T07:26:21.344Z", - "isArchived": false, - "sourceWorkflowId": null, - "triggerCount": 1, + "active": false, "nodes": [ { + "parameters": { + "httpMethod": "POST", + "path": "uptime-kuma", + "responseMode": "responseNode", + "options": {} + }, "name": "Uptime Kuma Webhook", "webhookId": "95de5809-c2a6-4ba1-a472-89debbc46fbb", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [ - 256, - 304 + 144, + 256 ], - "parameters": { - "path": "uptime-kuma", - "options": {}, - "httpMethod": "POST", - "responseMode": "responseNode" - }, - "id": "3d7a7e98-5b78-4709-9474-1e10bae2469b" + "id": "a4c37fdc-fe82-4d53-8cd9-0d6af7afc90f" }, { + "parameters": { + "jsCode": "const webhookData = $input.first().json;\nconst body = webhookData.body || webhookData;\n\n// УМНАЯ ПРОВЕРКА: если monitor_name пуст или 'Unknown', берем домен из URL\nlet monitorName = body.monitor_name || 'Unknown';\nif (monitorName === 'Unknown' || !monitorName) {\n const url = body.monitor_url || '';\n monitorName = url ? url.replace(/https?:\\/\\//, '').split('/')[0] : 'Unknown Service';\n}\n\nconst monitorUrl = body.monitor_url || 'N/A';\nconst status = parseInt(body.heartbeat_status) || 0;\nconst message = body.heartbeat_message || 'Service is down';\n\nconst ctMatch = monitorName.match(/\\((\\d+)\\)/);\nconst ctId = ctMatch ? ctMatch[1] : null;\n\n// Создаем четкий заголовок для Gitea\nconst giteaTitle = `AUTO-FIX: ${monitorName} DOWN`;\n\nreturn [{\n json: {\n monitorName,\n monitorUrl,\n status,\n message,\n ctId,\n giteaTitle,\n timestamp: new Date().toISOString(),\n shouldAlert: status === 0 && ctId !== null\n }\n}];" + }, "name": "Extract Info", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 480, - 304 + 368, + 256 ], - "parameters": { - "jsCode": "const webhookData = $input.first().json;\nconst body = webhookData.body || webhookData;\n\nconst monitorName = body.monitor_name || 'Unknown';\nconst monitorUrl = body.monitor_url || '';\nconst status = parseInt(body.heartbeat_status) || 0;\nconst message = body.heartbeat_message || 'Service is down';\n\nconst ctMatch = monitorName.match(/\\((\\d+)\\)/);\nconst ctId = ctMatch ? ctMatch[1] : null;\n\nreturn [{\n json: {\n monitorName,\n monitorUrl,\n status,\n message,\n ctId,\n timestamp: new Date().toISOString(),\n shouldAlert: status === 0 && ctId !== null\n }\n}];" - }, - "id": "49a459f5-1b1e-4bd6-83d9-b231a7d018c6" + "id": "23e46b7d-28db-4d26-b90b-f86f49d216bc" }, { + "parameters": { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 2 + }, + "conditions": [ + { + "id": "b1e6f2a0-1111-4222-8333-444455556666", + "leftValue": "={{ $json.shouldAlert }}", + "rightValue": true, + "operator": { + "type": "boolean", + "operation": "equals" + } + } + ], + "combinator": "and" + }, + "options": {} + }, "name": "Should Create Issue?", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [ - 720, - 304 + 608, + 256 ], - "parameters": { - "options": {}, - "conditions": { - "boolean": [ - { - "value1": "={{ $json.shouldAlert }}", - "value2": true - } - ], - "options": { - "version": 1, - "leftValue": "", - "caseSensitive": true, - "typeValidation": "strict" - }, - "combinator": "and" - } - }, - "id": "a5a56bde-cd3c-404c-959d-5eb4cf344f80" + "id": "2b7f557f-8d80-4266-8f67-6b1dc3c38f25" }, { - "name": "Create Gitea Issue", - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 944, - 208 - ], "parameters": { - "url": "http://192.168.1.140:3000/api/v1/repos/root/buryan-hub/issues", "method": "POST", - "options": {}, - "jsonBody": "={{ JSON.stringify({ title: \"AUTO-FIX: \" + $json.monitorName + \" DOWN\", body: \"CT_DOWN:\" + $json.ctId + \"\\n\\nАвтоматическое восстановление \" + $json.monitorName + \".\\n\\nURL: \" + $json.monitorUrl + \"\\nMessage: \" + $json.message + \"\\nTime: \" + $json.timestamp, labels: [2] }) }}", - "sendBody": true, + "url": "http://192.168.1.140:3000/api/v1/repos/agent-qwen/buryan-infra/issues", "sendHeaders": true, - "specifyBody": "json", "headerParameters": { "parameters": [ { @@ -95,34 +83,22 @@ "value": "application/json" } ] - } + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={{ JSON.stringify({ title: $json.giteaTitle, body: \"CT_DOWN: \" + $json.ctId + \"\\n\\nАвтоматическое восстановление: \" + $json.monitorName + \".\\n\\nURL: \" + $json.monitorUrl + \"\\nMessage: \" + $json.message + \"\\nTime: \" + $json.timestamp, labels: [2] }) }}", + "options": {} }, - "id": "ffc579ec-a0cf-41d4-9444-66fc9af71bfb" - }, - { - "name": "Respond", - "type": "n8n-nodes-base.respondToWebhook", - "typeVersion": 1.1, - "position": [ - 1184, - 208 - ], - "parameters": { - "options": {}, - "respondWith": "json", - "responseBody": "={{ JSON.stringify({ ok: true, issue_created: $json.html_url || null }) }}" - }, - "id": "b7050fd1-a247-4b50-846d-4358e7073e89" - }, - { - "id": "06142831-0672-469e-898e-79463b84f3db", - "name": "Notify Telegram", + "name": "Create Gitea Issue", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ - 1200, - 304 + 832, + 160 ], + "id": "40bcfe34-b905-4ab2-ac2d-5de5ad5e9d5b" + }, + { "parameters": { "method": "POST", "url": "https://193.233.210.184/tg-api/bot8668603602:AAHVmUmq44dcomw8QOfw_qj1aICXuT5c5XU/sendMessage", @@ -144,7 +120,7 @@ }, { "name": "text", - "value": "=🚨 {{ $json.monitorName }} DOWN\n\nURL: {{ $json.monitorUrl }}\nВремя: {{ new Date().toLocaleString(\"ru-RU\") }}\n\nIssue создан в Gitea" + "value": "=🚨 {{ $json.monitorName }} DOWN\n\nURL: {{ $json.monitorUrl }}\nВремя: {{ new Date().toLocaleString(\"ru-RU\") }}\n\n✅ Issue создан в Gitea: {{ $json.giteaTitle }}" }, { "name": "parse_mode", @@ -154,34 +130,34 @@ }, "options": { "allowUnauthorizedCerts": true - }, - "proxy": "http://193.233.210.184:1080" - } + } + }, + "name": "Notify Telegram", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.2, + "position": [ + 1088, + 256 + ], + "id": "9cbd83b9-944f-4d3f-9803-62ccf51cd458" + }, + { + "parameters": { + "respondWith": "json", + "responseBody": "={{ JSON.stringify({ ok: true, issue_created: $json.html_url || null }) }}", + "options": {} + }, + "name": "Respond", + "type": "n8n-nodes-base.respondToWebhook", + "typeVersion": 1.1, + "position": [ + 1312, + 256 + ], + "id": "6eac3128-5c63-4315-89af-4fb0be610522" } ], "connections": { - "Extract Info": { - "main": [ - [ - { - "node": "Should Create Issue?", - "type": "main", - "index": 0 - } - ] - ] - }, - "Create Gitea Issue": { - "main": [ - [ - { - "node": "Notify Telegram", - "type": "main", - "index": 0 - } - ] - ] - }, "Uptime Kuma Webhook": { "main": [ [ @@ -193,6 +169,17 @@ ] ] }, + "Extract Info": { + "main": [ + [ + { + "node": "Should Create Issue?", + "type": "main", + "index": 0 + } + ] + ] + }, "Should Create Issue?": { "main": [ [ @@ -201,6 +188,24 @@ "type": "main", "index": 0 } + ], + [ + { + "node": "Respond", + "type": "main", + "index": 0 + } + ] + ] + }, + "Create Gitea Issue": { + "main": [ + [ + { + "node": "Notify Telegram", + "type": "main", + "index": 0 + } ] ] }, @@ -216,14 +221,10 @@ ] } }, - "nodeGroups": [], "settings": { "binaryMode": "separate", "executionOrder": "v1" }, - "staticData": null, - "pinData": {}, - "meta": null, - "tags": [] + "staticData": null } ]