793 lines
25 KiB
JSON
793 lines
25 KiB
JSON
{
|
|
"updatedAt": "2026-05-22T21:55:07.241Z",
|
|
"createdAt": "2026-05-09T19:58:19.095Z",
|
|
"id": "fmywVBIanfxOfDlI",
|
|
"name": "Grafana Alert → AI → Gotify v1.4",
|
|
"description": null,
|
|
"active": true,
|
|
"isArchived": false,
|
|
"nodes": [
|
|
{
|
|
"parameters": {
|
|
"httpMethod": "POST",
|
|
"path": "grafana-alert",
|
|
"options": {}
|
|
},
|
|
"id": "0871c06f-a76f-43fe-93f0-45d48f5d6b1a",
|
|
"name": "Grafana Webhook",
|
|
"type": "n8n-nodes-base.webhook",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
0,
|
|
0
|
|
],
|
|
"webhookId": "0492788e-db4e-4d15-9572-9d6c3efc80c3"
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "// Parse Grafana alert payload into a clean summary for the LLM\nconst alerts = $input.first().json.body?.alerts || $input.first().json.alerts || [];\n\nconst parsed = alerts.map(a => ({\n status: a.status || 'unknown',\n alertName: a.labels?.alertname || 'Unnamed Alert',\n host: a.labels?.host || a.labels?.instance || 'unknown host',\n severity: a.labels?.severity || 'warning',\n summary: a.annotations?.summary || '',\n description: a.annotations?.description || '',\n value: a.valueString || '',\n startsAt: a.startsAt || '',\n endsAt: a.endsAt || ''\n}));\n\nconst alertText = parsed.map(a =>\n `[${a.status.toUpperCase()}] ${a.alertName} on ${a.host}\\nSeverity: ${a.severity}\\nSummary: ${a.summary}\\nDescription: ${a.description}\\nValue: ${a.value}\\nStarted: ${a.startsAt}`\n).join('\\n---\\n');\n\nreturn [{\n json: {\n alertText,\n alertCount: parsed.length,\n hasResolved: parsed.some(a => a.status === 'resolved'),\n hasFiring: parsed.some(a => a.status === 'firing'),\n parsed\n }\n}];"
|
|
},
|
|
"id": "134ce285-5e4e-41c9-ab50-50f429592065",
|
|
"name": "Parse Alert Payload",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
224,
|
|
0
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "const parsed = $('Parse Alert Payload').first().json;\nconst now = new Date();\nconst hour = now.getHours();\nconst fingerprint = (parsed.parsed || [])\n .map(a => `${a.alertName}:${a.host}`)\n .sort().join('|') || 'unknown';\nreturn [{ json: { ...parsed, fingerprint, isNightTime: hour >= 0 && hour < 7 } }];\n"
|
|
},
|
|
"id": "dabc016f-5258-4e55-bd2c-9d0eddc5e5e4",
|
|
"name": "Build Fingerprint",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
448,
|
|
0
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"operation": "executeQuery",
|
|
"query": "{{ 'SELECT fingerprint, last_seen FROM grafana_alert_dedup WHERE fingerprint = \\'' + $json.fingerprint + '\\' AND last_seen > NOW() - INTERVAL \\'30 minutes\\' LIMIT 1;' }}",
|
|
"options": {}
|
|
},
|
|
"id": "48f75ff7-46ca-42b3-a8fa-b70e00ccf11b",
|
|
"name": "Lookup Dedup",
|
|
"type": "n8n-nodes-base.postgres",
|
|
"typeVersion": 2.5,
|
|
"position": [
|
|
672,
|
|
0
|
|
],
|
|
"alwaysOutputData": true,
|
|
"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 alreadySeen = rows.length > 0;\nconst isLowPriority = !alertData.hasFiring;\nconst suppressNight = alertData.isNightTime && isLowPriority;\nconst suppress = alreadySeen || suppressNight;\nreturn [{ json: { ...alertData, suppress, shouldNotify: suppress ? 'no' : 'yes', suppressReason: alreadySeen ? 'dedup' : suppressNight ? 'night_suppress' : null } }];\n"
|
|
},
|
|
"id": "71143216-2d33-4f42-8204-25c4933e4e9f",
|
|
"name": "Check Should Notify",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
896,
|
|
0
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"conditions": {
|
|
"options": {
|
|
"caseSensitive": true,
|
|
"leftValue": "",
|
|
"typeValidation": "strict",
|
|
"version": 1
|
|
},
|
|
"conditions": [
|
|
{
|
|
"id": "cc41d77c-b659-4c6f-8e71-96a13dced242",
|
|
"leftValue": "={{ $json.shouldNotify }}",
|
|
"rightValue": "yes",
|
|
"operator": {
|
|
"type": "string",
|
|
"operation": "equals"
|
|
}
|
|
}
|
|
],
|
|
"combinator": "and"
|
|
},
|
|
"options": {}
|
|
},
|
|
"id": "280b1128-1e31-4e3e-bf25-f3c186395462",
|
|
"name": "Should Notify?",
|
|
"type": "n8n-nodes-base.if",
|
|
"typeVersion": 2.2,
|
|
"position": [
|
|
1120,
|
|
0
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "const d = $input.first().json;\nconst first = (d.parsed || [])[0] || {};\nreturn [{ json: {\n fingerprint: d.fingerprint,\n dedupAlertName: first.alertName || 'unknown',\n dedupHost: first.host || 'unknown'\n} }];"
|
|
},
|
|
"id": "0fd4eaf5-c883-4732-8144-d188552d5efa",
|
|
"name": "Prepare Dedup Data",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
1344,
|
|
0
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"operation": "executeQuery",
|
|
"query": "{{ 'INSERT INTO grafana_alert_dedup (fingerprint, last_seen, alert_name, host) VALUES (\\'' + $json.fingerprint + '\\', NOW(), \\'' + $json.dedupAlertName + '\\', \\'' + $json.dedupHost + '\\') ON CONFLICT (fingerprint) DO UPDATE SET last_seen = NOW();' }}",
|
|
"options": {}
|
|
},
|
|
"id": "04297e85-5a83-420d-a05d-f2ea23c5aa5e",
|
|
"name": "Upsert Dedup Record",
|
|
"type": "n8n-nodes-base.postgres",
|
|
"typeVersion": 2.5,
|
|
"position": [
|
|
1568,
|
|
0
|
|
],
|
|
"credentials": {
|
|
"postgres": {
|
|
"id": "n9svoXemqSZoNNUB",
|
|
"name": "Postgres account"
|
|
}
|
|
},
|
|
"continueOnFail": true
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "// Build the LiteLLM request body from Parse Alert Payload data.\n// Doing this in a Code node (instead of inline in the HTTP node) ensures\n// the expression resolves cleanly — same pattern as RSS Digest which is stable.\nconst alertData = $('Parse Alert Payload').first().json;\nconst alertText = alertData.alertText || '(no alert text received)';\n\nreturn [{\n json: {\n aiBody: {\n model: 'medium',\n messages: [\n {\n role: 'system',\n content: 'You are a concise homelab monitoring assistant. Summarize infrastructure alerts in 2-3 sentences. Include: what happened, which host, severity, and a suggested action. Keep it brief — this goes to a phone notification.'\n },\n {\n role: 'user',\n content: 'Summarize this Grafana alert:\\n\\n' + alertText\n }\n ],\n max_tokens: 200,\n temperature: 0.3\n }\n }\n}];"
|
|
},
|
|
"id": "3e5ea479-7184-45ff-93c7-328968380b9f",
|
|
"name": "Prepare AI Request",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
1792,
|
|
0
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"method": "POST",
|
|
"url": "http://10.5.30.6:4000/v1/chat/completions",
|
|
"sendHeaders": true,
|
|
"headerParameters": {
|
|
"parameters": [
|
|
{
|
|
"name": "Content-Type",
|
|
"value": "application/json"
|
|
},
|
|
{
|
|
"name": "Authorization",
|
|
"value": "=Bearer {{ $env.LITELLM_API_KEY }}"
|
|
}
|
|
]
|
|
},
|
|
"sendBody": true,
|
|
"specifyBody": "json",
|
|
"jsonBody": "={{ JSON.stringify($json.aiBody) }}",
|
|
"options": {
|
|
"response": {
|
|
"response": {
|
|
"responseFormat": "json"
|
|
}
|
|
},
|
|
"timeout": 120000
|
|
}
|
|
},
|
|
"id": "799c6592-9ef4-456a-90c1-4b42fa07855d",
|
|
"name": "LiteLLM Summarize",
|
|
"type": "n8n-nodes-base.httpRequest",
|
|
"typeVersion": 4.2,
|
|
"position": [
|
|
2016,
|
|
0
|
|
],
|
|
"continueOnFail": true
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "const response = $input.first().json;\nconst alertData = $('Parse Alert Payload').first().json;\n\nlet summary;\nif (response.error || response.errorMessage) {\n summary = 'AI summary unavailable — check LiteLLM.';\n} else {\n summary = response.choices?.[0]?.message?.content || 'Could not generate summary';\n}\n\nconst title = alertData.hasFiring\n ? `🔥 Alert Firing (${alertData.alertCount})`\n : `✅ Alert Resolved (${alertData.alertCount})`;\n\nconst priority = alertData.hasFiring ? 8 : 2;\n\nreturn [{\n json: {\n title,\n message: summary,\n priority\n }\n}];"
|
|
},
|
|
"id": "2de2e9cc-8dfe-42e2-9b40-fc518ae7f8ec",
|
|
"name": "Format Notification",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
2240,
|
|
0
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"message": "={{ $json.message }}",
|
|
"additionalFields": {
|
|
"priority": "={{ $json.priority }}",
|
|
"title": "={{ $json.title }}"
|
|
},
|
|
"options": {
|
|
"contentType": "text/plain"
|
|
}
|
|
},
|
|
"id": "1d1a4e02-fb80-4a3e-95ce-a9431ddb1c43",
|
|
"name": "Push to Gotify",
|
|
"type": "n8n-nodes-base.gotify",
|
|
"typeVersion": 1,
|
|
"position": [
|
|
2464,
|
|
0
|
|
],
|
|
"credentials": {
|
|
"gotifyApi": {
|
|
"id": "DXdYZDfVZecDTaNU",
|
|
"name": "Gotify Grafana Warning"
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"connections": {
|
|
"Grafana Webhook": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Parse Alert Payload",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Parse Alert Payload": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Build Fingerprint",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Build Fingerprint": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Lookup Dedup",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Lookup Dedup": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Check Should Notify",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Check Should Notify": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Should Notify?",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Should Notify?": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Prepare Dedup Data",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Prepare Dedup Data": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Upsert Dedup Record",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Upsert Dedup Record": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Prepare AI Request",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Prepare AI Request": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "LiteLLM Summarize",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"LiteLLM Summarize": {
|
|
"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": {},
|
|
"versionId": "b4e4c7e1-41d4-4a3b-a3f8-1d2d243bc863",
|
|
"activeVersionId": "b4e4c7e1-41d4-4a3b-a3f8-1d2d243bc863",
|
|
"versionCounter": 37,
|
|
"triggerCount": 1,
|
|
"shared": [
|
|
{
|
|
"updatedAt": "2026-05-09T19:58:19.095Z",
|
|
"createdAt": "2026-05-09T19:58:19.095Z",
|
|
"role": "workflow:owner",
|
|
"workflowId": "fmywVBIanfxOfDlI",
|
|
"projectId": "dxCRnBdX5uJizCGa",
|
|
"project": {
|
|
"updatedAt": "2026-05-06T01:10:37.484Z",
|
|
"createdAt": "2026-05-06T01:08:07.721Z",
|
|
"id": "dxCRnBdX5uJizCGa",
|
|
"name": "Wilfred Fizzlepoof <admin@paccoco.com>",
|
|
"type": "personal",
|
|
"icon": null,
|
|
"description": null,
|
|
"creatorId": "47b2227f-2fc2-4a08-bd35-ea157b92df0d"
|
|
}
|
|
}
|
|
],
|
|
"tags": [],
|
|
"activeVersion": {
|
|
"updatedAt": "2026-05-22T21:55:07.243Z",
|
|
"createdAt": "2026-05-22T21:55:07.243Z",
|
|
"versionId": "b4e4c7e1-41d4-4a3b-a3f8-1d2d243bc863",
|
|
"workflowId": "fmywVBIanfxOfDlI",
|
|
"nodes": [
|
|
{
|
|
"parameters": {
|
|
"httpMethod": "POST",
|
|
"path": "grafana-alert",
|
|
"options": {}
|
|
},
|
|
"id": "0871c06f-a76f-43fe-93f0-45d48f5d6b1a",
|
|
"name": "Grafana Webhook",
|
|
"type": "n8n-nodes-base.webhook",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
0,
|
|
0
|
|
],
|
|
"webhookId": "0492788e-db4e-4d15-9572-9d6c3efc80c3"
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "// Parse Grafana alert payload into a clean summary for the LLM\nconst alerts = $input.first().json.body?.alerts || $input.first().json.alerts || [];\n\nconst parsed = alerts.map(a => ({\n status: a.status || 'unknown',\n alertName: a.labels?.alertname || 'Unnamed Alert',\n host: a.labels?.host || a.labels?.instance || 'unknown host',\n severity: a.labels?.severity || 'warning',\n summary: a.annotations?.summary || '',\n description: a.annotations?.description || '',\n value: a.valueString || '',\n startsAt: a.startsAt || '',\n endsAt: a.endsAt || ''\n}));\n\nconst alertText = parsed.map(a =>\n `[${a.status.toUpperCase()}] ${a.alertName} on ${a.host}\\nSeverity: ${a.severity}\\nSummary: ${a.summary}\\nDescription: ${a.description}\\nValue: ${a.value}\\nStarted: ${a.startsAt}`\n).join('\\n---\\n');\n\nreturn [{\n json: {\n alertText,\n alertCount: parsed.length,\n hasResolved: parsed.some(a => a.status === 'resolved'),\n hasFiring: parsed.some(a => a.status === 'firing'),\n parsed\n }\n}];"
|
|
},
|
|
"id": "134ce285-5e4e-41c9-ab50-50f429592065",
|
|
"name": "Parse Alert Payload",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
224,
|
|
0
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "const parsed = $('Parse Alert Payload').first().json;\nconst now = new Date();\nconst hour = now.getHours();\nconst fingerprint = (parsed.parsed || [])\n .map(a => `${a.alertName}:${a.host}`)\n .sort().join('|') || 'unknown';\nreturn [{ json: { ...parsed, fingerprint, isNightTime: hour >= 0 && hour < 7 } }];\n"
|
|
},
|
|
"id": "dabc016f-5258-4e55-bd2c-9d0eddc5e5e4",
|
|
"name": "Build Fingerprint",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
448,
|
|
0
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"operation": "executeQuery",
|
|
"query": "{{ 'SELECT fingerprint, last_seen FROM grafana_alert_dedup WHERE fingerprint = \\'' + $json.fingerprint + '\\' AND last_seen > NOW() - INTERVAL \\'30 minutes\\' LIMIT 1;' }}",
|
|
"options": {}
|
|
},
|
|
"id": "48f75ff7-46ca-42b3-a8fa-b70e00ccf11b",
|
|
"name": "Lookup Dedup",
|
|
"type": "n8n-nodes-base.postgres",
|
|
"typeVersion": 2.5,
|
|
"position": [
|
|
672,
|
|
0
|
|
],
|
|
"alwaysOutputData": true,
|
|
"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 alreadySeen = rows.length > 0;\nconst isLowPriority = !alertData.hasFiring;\nconst suppressNight = alertData.isNightTime && isLowPriority;\nconst suppress = alreadySeen || suppressNight;\nreturn [{ json: { ...alertData, suppress, shouldNotify: suppress ? 'no' : 'yes', suppressReason: alreadySeen ? 'dedup' : suppressNight ? 'night_suppress' : null } }];\n"
|
|
},
|
|
"id": "71143216-2d33-4f42-8204-25c4933e4e9f",
|
|
"name": "Check Should Notify",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
896,
|
|
0
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"conditions": {
|
|
"options": {
|
|
"caseSensitive": true,
|
|
"leftValue": "",
|
|
"typeValidation": "strict",
|
|
"version": 1
|
|
},
|
|
"conditions": [
|
|
{
|
|
"id": "cc41d77c-b659-4c6f-8e71-96a13dced242",
|
|
"leftValue": "={{ $json.shouldNotify }}",
|
|
"rightValue": "yes",
|
|
"operator": {
|
|
"type": "string",
|
|
"operation": "equals"
|
|
}
|
|
}
|
|
],
|
|
"combinator": "and"
|
|
},
|
|
"options": {}
|
|
},
|
|
"id": "280b1128-1e31-4e3e-bf25-f3c186395462",
|
|
"name": "Should Notify?",
|
|
"type": "n8n-nodes-base.if",
|
|
"typeVersion": 2.2,
|
|
"position": [
|
|
1120,
|
|
0
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "const d = $input.first().json;\nconst first = (d.parsed || [])[0] || {};\nreturn [{ json: {\n fingerprint: d.fingerprint,\n dedupAlertName: first.alertName || 'unknown',\n dedupHost: first.host || 'unknown'\n} }];"
|
|
},
|
|
"id": "0fd4eaf5-c883-4732-8144-d188552d5efa",
|
|
"name": "Prepare Dedup Data",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
1344,
|
|
0
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"operation": "executeQuery",
|
|
"query": "{{ 'INSERT INTO grafana_alert_dedup (fingerprint, last_seen, alert_name, host) VALUES (\\'' + $json.fingerprint + '\\', NOW(), \\'' + $json.dedupAlertName + '\\', \\'' + $json.dedupHost + '\\') ON CONFLICT (fingerprint) DO UPDATE SET last_seen = NOW();' }}",
|
|
"options": {}
|
|
},
|
|
"id": "04297e85-5a83-420d-a05d-f2ea23c5aa5e",
|
|
"name": "Upsert Dedup Record",
|
|
"type": "n8n-nodes-base.postgres",
|
|
"typeVersion": 2.5,
|
|
"position": [
|
|
1568,
|
|
0
|
|
],
|
|
"credentials": {
|
|
"postgres": {
|
|
"id": "n9svoXemqSZoNNUB",
|
|
"name": "Postgres account"
|
|
}
|
|
},
|
|
"continueOnFail": true
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "// Build the LiteLLM request body from Parse Alert Payload data.\n// Doing this in a Code node (instead of inline in the HTTP node) ensures\n// the expression resolves cleanly — same pattern as RSS Digest which is stable.\nconst alertData = $('Parse Alert Payload').first().json;\nconst alertText = alertData.alertText || '(no alert text received)';\n\nreturn [{\n json: {\n aiBody: {\n model: 'medium',\n messages: [\n {\n role: 'system',\n content: 'You are a concise homelab monitoring assistant. Summarize infrastructure alerts in 2-3 sentences. Include: what happened, which host, severity, and a suggested action. Keep it brief — this goes to a phone notification.'\n },\n {\n role: 'user',\n content: 'Summarize this Grafana alert:\\n\\n' + alertText\n }\n ],\n max_tokens: 200,\n temperature: 0.3\n }\n }\n}];"
|
|
},
|
|
"id": "3e5ea479-7184-45ff-93c7-328968380b9f",
|
|
"name": "Prepare AI Request",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
1792,
|
|
0
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"method": "POST",
|
|
"url": "http://10.5.30.6:4000/v1/chat/completions",
|
|
"sendHeaders": true,
|
|
"headerParameters": {
|
|
"parameters": [
|
|
{
|
|
"name": "Content-Type",
|
|
"value": "application/json"
|
|
},
|
|
{
|
|
"name": "Authorization",
|
|
"value": "=Bearer {{ $env.LITELLM_API_KEY }}"
|
|
}
|
|
]
|
|
},
|
|
"sendBody": true,
|
|
"specifyBody": "json",
|
|
"jsonBody": "={{ JSON.stringify($json.aiBody) }}",
|
|
"options": {
|
|
"response": {
|
|
"response": {
|
|
"responseFormat": "json"
|
|
}
|
|
},
|
|
"timeout": 120000
|
|
}
|
|
},
|
|
"id": "799c6592-9ef4-456a-90c1-4b42fa07855d",
|
|
"name": "LiteLLM Summarize",
|
|
"type": "n8n-nodes-base.httpRequest",
|
|
"typeVersion": 4.2,
|
|
"position": [
|
|
2016,
|
|
0
|
|
],
|
|
"continueOnFail": true
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "const response = $input.first().json;\nconst alertData = $('Parse Alert Payload').first().json;\n\nlet summary;\nif (response.error || response.errorMessage) {\n summary = 'AI summary unavailable — check LiteLLM.';\n} else {\n summary = response.choices?.[0]?.message?.content || 'Could not generate summary';\n}\n\nconst title = alertData.hasFiring\n ? `🔥 Alert Firing (${alertData.alertCount})`\n : `✅ Alert Resolved (${alertData.alertCount})`;\n\nconst priority = alertData.hasFiring ? 8 : 2;\n\nreturn [{\n json: {\n title,\n message: summary,\n priority\n }\n}];"
|
|
},
|
|
"id": "2de2e9cc-8dfe-42e2-9b40-fc518ae7f8ec",
|
|
"name": "Format Notification",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
2240,
|
|
0
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"message": "={{ $json.message }}",
|
|
"additionalFields": {
|
|
"priority": "={{ $json.priority }}",
|
|
"title": "={{ $json.title }}"
|
|
},
|
|
"options": {
|
|
"contentType": "text/plain"
|
|
}
|
|
},
|
|
"id": "1d1a4e02-fb80-4a3e-95ce-a9431ddb1c43",
|
|
"name": "Push to Gotify",
|
|
"type": "n8n-nodes-base.gotify",
|
|
"typeVersion": 1,
|
|
"position": [
|
|
2464,
|
|
0
|
|
],
|
|
"credentials": {
|
|
"gotifyApi": {
|
|
"id": "DXdYZDfVZecDTaNU",
|
|
"name": "Gotify Grafana Warning"
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"connections": {
|
|
"Grafana Webhook": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Parse Alert Payload",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Parse Alert Payload": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Build Fingerprint",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Build Fingerprint": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Lookup Dedup",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Lookup Dedup": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Check Should Notify",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Check Should Notify": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Should Notify?",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Should Notify?": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Prepare Dedup Data",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Prepare Dedup Data": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Upsert Dedup Record",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Upsert Dedup Record": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Prepare AI Request",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Prepare AI Request": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "LiteLLM Summarize",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"LiteLLM Summarize": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Format Notification",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Format Notification": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Push to Gotify",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
}
|
|
},
|
|
"authors": "Wilfred Fizzlepoof",
|
|
"name": null,
|
|
"description": null,
|
|
"autosaved": false,
|
|
"workflowPublishHistory": [
|
|
{
|
|
"createdAt": "2026-05-22T21:55:07.301Z",
|
|
"id": 319,
|
|
"workflowId": "fmywVBIanfxOfDlI",
|
|
"versionId": "b4e4c7e1-41d4-4a3b-a3f8-1d2d243bc863",
|
|
"event": "deactivated",
|
|
"userId": "47b2227f-2fc2-4a08-bd35-ea157b92df0d"
|
|
},
|
|
{
|
|
"createdAt": "2026-05-22T21:55:07.325Z",
|
|
"id": 320,
|
|
"workflowId": "fmywVBIanfxOfDlI",
|
|
"versionId": "b4e4c7e1-41d4-4a3b-a3f8-1d2d243bc863",
|
|
"event": "activated",
|
|
"userId": "47b2227f-2fc2-4a08-bd35-ea157b92df0d"
|
|
}
|
|
]
|
|
}
|
|
}
|