160 lines
4.7 KiB
JSON
160 lines
4.7 KiB
JSON
{
|
|
"name": "雙環境健康監控 (UAT + GCP)",
|
|
"nodes": [
|
|
{
|
|
"parameters": {
|
|
"rule": {
|
|
"interval": [
|
|
{
|
|
"field": "minutes",
|
|
"minutesInterval": 5
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"id": "schedule",
|
|
"name": "每 5 分鐘執行",
|
|
"type": "n8n-nodes-base.scheduleTrigger",
|
|
"typeVersion": 1.2,
|
|
"position": [240, 300]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"url": "https://mo.wooo.work/health",
|
|
"options": {
|
|
"timeout": 10000
|
|
}
|
|
},
|
|
"id": "uat-health",
|
|
"name": "UAT 健康檢查",
|
|
"type": "n8n-nodes-base.httpRequest",
|
|
"typeVersion": 4.2,
|
|
"position": [460, 200],
|
|
"continueOnFail": true
|
|
},
|
|
{
|
|
"parameters": {
|
|
"url": "https://momo.wooo.work/health",
|
|
"options": {
|
|
"timeout": 10000
|
|
}
|
|
},
|
|
"id": "gcp-health",
|
|
"name": "GCP 健康檢查",
|
|
"type": "n8n-nodes-base.httpRequest",
|
|
"typeVersion": 4.2,
|
|
"position": [460, 400],
|
|
"continueOnFail": true
|
|
},
|
|
{
|
|
"parameters": {
|
|
"mode": "combine",
|
|
"combineBy": "combineAll",
|
|
"options": {}
|
|
},
|
|
"id": "merge",
|
|
"name": "合併結果",
|
|
"type": "n8n-nodes-base.merge",
|
|
"typeVersion": 3,
|
|
"position": [680, 300]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "const uatResult = $input.all()[0].json;\nconst gcpResult = $input.all()[1].json;\n\nconst now = new Date().toLocaleString('zh-TW', { timeZone: 'Asia/Taipei' });\n\nconst uatOk = uatResult.status === 'healthy';\nconst gcpOk = gcpResult.status === 'healthy';\n\nlet message = '';\nlet hasIssue = false;\n\nif (!uatOk || !gcpOk) {\n hasIssue = true;\n message = '🚨 <b>環境健康告警</b>\\n\\n';\n \n if (!uatOk) {\n message += '🟦 <b>UAT</b>: ❌ 異常\\n';\n message += ` 狀態: ${JSON.stringify(uatResult)}\\n`;\n } else {\n message += `🟦 <b>UAT</b>: ✅ 正常 (${uatResult.version})\\n`;\n }\n \n if (!gcpOk) {\n message += '🟥 <b>GCP</b>: ❌ 異常\\n';\n message += ` 狀態: ${JSON.stringify(gcpResult)}\\n`;\n } else {\n message += `🟥 <b>GCP</b>: ✅ 正常 (${gcpResult.version})\\n`;\n }\n \n message += `\\n⏰ <i>檢查時間: ${now}</i>`;\n}\n\nreturn [{\n json: {\n hasIssue,\n message,\n uatStatus: uatOk,\n gcpStatus: gcpOk,\n timestamp: now\n }\n}];"
|
|
},
|
|
"id": "process",
|
|
"name": "分析結果",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [900, 300]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"conditions": {
|
|
"options": {
|
|
"caseSensitive": true,
|
|
"leftValue": "",
|
|
"typeValidation": "strict"
|
|
},
|
|
"conditions": [
|
|
{
|
|
"id": "check-issue",
|
|
"leftValue": "={{ $json.hasIssue }}",
|
|
"rightValue": true,
|
|
"operator": {
|
|
"type": "boolean",
|
|
"operation": "equals"
|
|
}
|
|
}
|
|
],
|
|
"combinator": "and"
|
|
},
|
|
"options": {}
|
|
},
|
|
"id": "if-issue",
|
|
"name": "有問題?",
|
|
"type": "n8n-nodes-base.if",
|
|
"typeVersion": 2,
|
|
"position": [1120, 300]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"url": "https://api.telegram.org/bot<TELEGRAM_BOT_TOKEN>/sendMessage",
|
|
"sendBody": true,
|
|
"specifyBody": "json",
|
|
"jsonBody": "={\n \"chat_id\": \"5619078117\",\n \"parse_mode\": \"HTML\",\n \"text\": \"{{ $json.message }}\"\n}",
|
|
"options": {}
|
|
},
|
|
"id": "telegram",
|
|
"name": "發送告警",
|
|
"type": "n8n-nodes-base.httpRequest",
|
|
"typeVersion": 4.2,
|
|
"position": [1340, 200]
|
|
}
|
|
],
|
|
"connections": {
|
|
"每 5 分鐘執行": {
|
|
"main": [
|
|
[
|
|
{ "node": "UAT 健康檢查", "type": "main", "index": 0 },
|
|
{ "node": "GCP 健康檢查", "type": "main", "index": 0 }
|
|
]
|
|
]
|
|
},
|
|
"UAT 健康檢查": {
|
|
"main": [
|
|
[{ "node": "合併結果", "type": "main", "index": 0 }]
|
|
]
|
|
},
|
|
"GCP 健康檢查": {
|
|
"main": [
|
|
[{ "node": "合併結果", "type": "main", "index": 1 }]
|
|
]
|
|
},
|
|
"合併結果": {
|
|
"main": [
|
|
[{ "node": "分析結果", "type": "main", "index": 0 }]
|
|
]
|
|
},
|
|
"分析結果": {
|
|
"main": [
|
|
[{ "node": "有問題?", "type": "main", "index": 0 }]
|
|
]
|
|
},
|
|
"有問題?": {
|
|
"main": [
|
|
[{ "node": "發送告警", "type": "main", "index": 0 }],
|
|
[]
|
|
]
|
|
}
|
|
},
|
|
"settings": {
|
|
"executionOrder": "v1"
|
|
},
|
|
"staticData": null,
|
|
"tags": [],
|
|
"triggerCount": 0,
|
|
"updatedAt": "2026-02-07T14:30:00.000Z",
|
|
"versionId": "1"
|
|
}
|