Files
ewoooc/n8n-workflows/18-gcp-prod-health-monitor.json
OoO d6d8777e41
All checks were successful
CD Pipeline / deploy (push) Successful in 1m12s
V10.601 收斂 Gemini 與密鑰治理
2026-06-06 14:52:46 +08:00

113 lines
4.4 KiB
JSON
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"name": "GCP PROD 健康監控",
"nodes": [
{
"parameters": {
"rule": { "interval": [{ "field": "minutes", "minutesInterval": 5 }] }
},
"id": "schedule-trigger",
"name": "每 5 分鐘檢查",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [250, 300]
},
{
"parameters": {
"jsCode": "// GCP PROD 環境關鍵頁面\nconst pages = [\n { name: '首頁', url: 'https://momo.wooo.work/' },\n { name: '每日銷售', url: 'https://momo.wooo.work/daily_sales' },\n { name: '健康檢查', url: 'https://momo.wooo.work/health' }\n];\n\nreturn pages.map(p => ({ json: p }));"
},
"id": "define-pages",
"name": "定義檢查頁面",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [470, 300]
},
{
"parameters": {
"url": "={{ $json.url }}",
"options": {
"timeout": 15000,
"redirect": { "redirect": { "followRedirects": true } }
}
},
"id": "http-check",
"name": "HTTP 檢查",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.1,
"position": [690, 300],
"continueOnFail": true
},
{
"parameters": {
"jsCode": "const items = $input.all();\nconst errors = [];\n\nfor (const item of items) {\n const data = item.json;\n const statusCode = data.statusCode || data.status || 0;\n const hasError = data.error || statusCode >= 400 || statusCode === 0;\n \n if (hasError) {\n errors.push({\n name: data.name || '未知頁面',\n url: data.url || '未知',\n status: statusCode,\n error: data.error?.message || data.message || '連線失敗'\n });\n }\n}\n\nif (errors.length === 0) {\n return [{ json: { hasErrors: false, message: '所有頁面正常' } }];\n}\n\nconst errorText = errors.map(e => `❌ ${e.name}: ${e.status} - ${e.error}`).join('\\n');\nconst alertText = `🔴 *【PROD】MOMO Pro 頁面異常*\\n\\n🏢 環境: 🟥 *正式環境* (momo.wooo.work)\\n\\n${errorText}\\n\\n⚠ 請立即檢查 GCP 服務狀態!`;\n\nreturn [{ json: { \n hasErrors: true, \n errors: errors,\n telegramBody: {\n chat_id: '5619078117',\n text: alertText,\n parse_mode: 'Markdown'\n }\n} }];"
},
"id": "analyze-results",
"name": "分析結果",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [910, 300]
},
{
"parameters": {
"conditions": {
"options": { "caseSensitive": true },
"conditions": [{
"id": "has-errors",
"leftValue": "={{ $json.hasErrors }}",
"rightValue": true,
"operator": { "type": "boolean", "operation": "equals" }
}],
"combinator": "and"
}
},
"id": "if-errors",
"name": "有錯誤?",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [1130, 300]
},
{
"parameters": {
"method": "POST",
"url": "https://api.telegram.org/bot<TELEGRAM_BOT_TOKEN>/sendMessage",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ JSON.stringify($json.telegramBody) }}"
},
"id": "telegram-alert",
"name": "發送告警",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.1,
"position": [1350, 200]
},
{
"parameters": {},
"id": "healthy-noop",
"name": "正常 (不處理)",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [1350, 400]
}
],
"connections": {
"每 5 分鐘檢查": { "main": [[{ "node": "定義檢查頁面", "type": "main", "index": 0 }]] },
"定義檢查頁面": { "main": [[{ "node": "HTTP 檢查", "type": "main", "index": 0 }]] },
"HTTP 檢查": { "main": [[{ "node": "分析結果", "type": "main", "index": 0 }]] },
"分析結果": { "main": [[{ "node": "有錯誤?", "type": "main", "index": 0 }]] },
"有錯誤?": {
"main": [
[{ "node": "發送告警", "type": "main", "index": 0 }],
[{ "node": "正常 (不處理)", "type": "main", "index": 0 }]
]
}
},
"settings": { "executionOrder": "v1" },
"staticData": null,
"tags": [
{ "name": "監控", "id": "monitoring" },
{ "name": "PROD", "id": "prod" },
{ "name": "GCP", "id": "gcp" }
],
"triggerCount": 1,
"meta": { "instanceId": "momo-n8n" }
}