{ "name": "Infrastructure AI Self-Healing", "nodes": [ { "parameters": { "httpMethod": "POST", "path": "zabbix-incident", "responseMode": "lastNode", "options": {} }, "id": "", "name": "Zabbix Webhook Alert", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [ -1344, -352 ], "webhookId": "" }, { "parameters": { "promptType": "define", "text": "=You are a strict infrastructure parser. Read the Zabbix alert and output the correct Proxmox command based on the resource type by dynamically extracting the exact ID found in the text.\n\nRules:\n- If the alert is an LXC container (lxc/), format as 'pct start '.\n- If the alert is a Virtual Machine (qm/), format as 'qm start '.\n- If the alert is a general host alert (like CPU load, disk, or memory without a specific lxc/qm ID), set \"actionCommand\" to \"none\".\n\nExample 1:\nAlert: Proxmox VE: LXC [node/test (lxc/109)]: Not running\nOutput: {\"actionCommand\": \"pct start 109\"}\n\nExample 2:\nAlert: Proxmox VE: VM [node/prod (qm/205)]: Not running\nOutput: {\"actionCommand\": \"qm start 205\"}\n\nCurrent Zabbix Event Name: \n{{ $json.body.event_name }}\n\nCurrent Zabbix Message:\n{{ $json.body.message }}\n\nOutput ONLY a raw JSON object with no markdown ticks or extra text, following this exact structure (replace with the actual ID extracted from the current alert):\n{\n \"actionCommand\": \"pct start \"\n}", "options": { "systemMessage": "You are an SRE AI Assistant. You analyze homelab issues and prepare remediation plans. Aftert preparing resolve the issues presented" } }, "id": "", "name": "AI Incident Analyzer", "type": "@n8n/n8n-nodes-langchain.agent", "typeVersion": 1.7, "position": [ -864, -368 ] }, { "parameters": { "model": "qwen2.5:3b", "options": { "numBatch": 1024, "numThread": 2 } }, "id": "", "name": "Ollama Chat Model", "type": "@n8n/n8n-nodes-langchain.lmChatOllama", "typeVersion": 1, "position": [ -864, -176 ], "credentials": { "ollamaApi": { "id": "", "name": "Ollama account" } } }, { "parameters": { "fromEmail": "", "toEmail": "", "subject": "={{ \"[Zabbix Auto-Remediation] Executed: \" + JSON.parse($('AI Incident Analyzer').first().json.output).actionCommand }}", "emailFormat": "html", "html": "=
\n

\n [Automated Homelab Self-Healing]\n

\n \n

\n An incident was automatically detected by Zabbix, evaluated by Local AI, and processed via remote pipeline.\n

\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Event Details
Event:{{ $('Zabbix Webhook Alert').first().json.body.event_name }}
Message:{{ $('Zabbix Webhook Alert').first().json.body.message }}
Remediation Status
Action Executed:\n {{ JSON.parse($('AI Incident Analyzer').first().json.output).actionCommand }}\n
\n\n

\n This fix was executed automatically by your n8n homelab pipeline.\n

\n
", "options": {} }, "id": "", "name": "Send Approval Email", "type": "n8n-nodes-base.emailSend", "typeVersion": 2, "position": [ -240, -368 ], "webhookId": "", "credentials": { "smtp": { "id": "", "name": "SMTP account" } } }, { "parameters": { "command": "={{ JSON.parse($json.output).actionCommand }}" }, "type": "n8n-nodes-base.ssh", "typeVersion": 1, "position": [ -496, -368 ], "id": "", "name": "Execute a command", "credentials": { "sshPassword": { "id": "", "name": "SSH Password account" } } }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "", "version": 3 }, "conditions": [ { "id": "", "leftValue": "={{ $json.body.message }}", "rightValue": "Problem started", "operator": { "type": "string", "operation": "contains" } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ -1120, -352 ], "id": "", "name": "Filter Active Problems" } ], "pinData": {}, "connections": { "Zabbix Webhook Alert": { "main": [ [ { "node": "Filter Active Problems", "type": "main", "index": 0 } ] ] }, "AI Incident Analyzer": { "main": [ [ { "node": "Execute a command", "type": "main", "index": 0 } ] ] }, "Ollama Chat Model": { "ai_languageModel": [ [ { "node": "AI Incident Analyzer", "type": "ai_languageModel", "index": 0 } ] ] }, "Send Approval Email": { "main": [ [] ] }, "Execute a command": { "main": [ [ { "node": "Send Approval Email", "type": "main", "index": 0 } ] ] }, "Filter Active Problems": { "main": [ [ { "node": "AI Incident Analyzer", "type": "main", "index": 0 } ] ] } }, "active": false, "settings": { "executionOrder": "v1", "binaryMode": "separate", "availableInMCP": false }, "versionId": "", "meta": { "templateCredsSetupCompleted": true, "instanceId": "" }, "id": "", "tags": [] }