使用定时触发器自托管运行时间监控
中级
这是一个DevOps, IT Ops领域的自动化工作流,包含 15 个节点。主要使用 Set, Gmail, Slack, Switch, HttpRequest 等节点。 使用定时触发器自托管运行时间监控
前置要求
- •Google 账号和 Gmail API 凭证
- •Slack Bot Token 或 Webhook URL
- •可能需要目标 API 的认证凭证
- •Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "26ba763460b97c249b82942b23b6384876dfeb9327513332e743c5f6219c2b8e"
},
"nodes": [
{
"id": "acb0acd0-9bb6-4491-a1ca-4aa9a7820bbc",
"name": "计划触发器",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
1440,
420
],
"parameters": {
"rule": {
"interval": [
{
"field": "hours",
"hoursInterval": 6
}
]
}
},
"typeVersion": 1.2
},
{
"id": "c6bb51c4-aec4-4a6d-ade2-1080bbbb6fb3",
"name": "计算状态",
"type": "n8n-nodes-base.set",
"position": [
2367,
460
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "b0cbcff5-bfcf-46a5-a386-65c4dd56c42f",
"name": "date",
"type": "string",
"value": "={{ $json.headers.date }}"
},
{
"id": "8c4155e4-bcc6-41dd-9582-346a57a7b997",
"name": "Property",
"type": "string",
"value": "={{ $json.Property }}"
},
{
"id": "f0320678-d352-486f-a633-9980c4fc73b2",
"name": "UP_FROM_UP",
"type": "boolean",
"value": "={{ $json.statusCode < 400 && $json.Status === 'UP' }}"
},
{
"id": "61783eb6-a683-44c9-aa0c-5fc5247da9fa",
"name": "DOWN_FROM_DOWN",
"type": "boolean",
"value": "={{ $json.statusCode >= 400 && $json.Status === 'DOWN' }}"
},
{
"id": "1052a69e-4456-445d-bdd9-2765b334cf64",
"name": "UP_FROM_DOWN",
"type": "boolean",
"value": "={{ $json.statusCode < 400 && $json.Status === 'DOWN' }}"
},
{
"id": "9af72278-5b29-406a-b4c5-f47f3d805063",
"name": "DOWN_FROM_UP",
"type": "boolean",
"value": "={{ $json.statusCode >= 400 && $json.Status === 'UP' }}"
}
]
}
},
"typeVersion": 3.3
},
{
"id": "50307dca-fa88-4a19-91a4-456866e529d4",
"name": "获取站点",
"type": "n8n-nodes-base.googleSheets",
"position": [
1700,
420
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1t2RT3lxyxXj3X1y6klWvyhEJEazpkT3Hpi2ttEJRVT4/edit#gid=0",
"cachedResultName": "dashboard"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1t2RT3lxyxXj3X1y6klWvyhEJEazpkT3Hpi2ttEJRVT4",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1t2RT3lxyxXj3X1y6klWvyhEJEazpkT3Hpi2ttEJRVT4/edit?usp=drivesdk",
"cachedResultName": "n8n uptime"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "XHvC7jIRR8A2TlUl",
"name": "Google Sheets account"
}
},
"typeVersion": 4.3
},
{
"id": "4b0cb0cc-282b-4be9-a4ca-0c4eb10d896e",
"name": "发送聊天警报",
"type": "n8n-nodes-base.slack",
"position": [
3100,
340
],
"parameters": {
"text": "=From: n8n uptime\nDate: {{ $('Calculate Status').item.json[\"date\"] }}\n\n{{ $('Calculate Status').item.json.Property }} is {{ $('Calculate Status').item.json[\"DOWN_FROM_UP\"] ? 'DOWN' : 'UP' }}",
"select": "channel",
"channelId": {
"__rl": true,
"mode": "list",
"value": "C06RS1WPUQ6",
"cachedResultName": "general"
},
"otherOptions": {}
},
"credentials": {
"slackApi": {
"id": "VfK3js0YdqBdQLGP",
"name": "Slack account"
}
},
"typeVersion": 2.1
},
{
"id": "ab303995-bd82-4aef-8fe1-ce808c4dbd33",
"name": "发送邮件警报",
"type": "n8n-nodes-base.gmail",
"position": [
2940,
340
],
"parameters": {
"sendTo": "no-reply@example.com",
"message": "=From: n8n uptime\nDate: {{ $('Calculate Status').item.json[\"date\"] }}\n\n{{ $('Calculate Status').item.json.Property }} is {{ $('Calculate Status').item.json[\"DOWN_FROM_UP\"] ? 'DOWN' : 'UP' }}",
"options": {
"senderName": "n8n uptime",
"appendAttribution": false
},
"subject": "=n8n uptime: {{ $('Calculate Status').item.json.Property }} is {{ $('Calculate Status').item.json[\"DOWN_FROM_UP\"] ? 'DOWN' : 'UP' }}",
"emailType": "text"
},
"credentials": {
"gmailOAuth2": {
"id": "Sf5Gfl9NiFTNXFWb",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "63343e68-be07-4d89-8363-140299dcf0b6",
"name": "记录正常运行时间事件",
"type": "n8n-nodes-base.googleSheets",
"position": [
2940,
520
],
"parameters": {
"columns": {
"value": {
"date": "={{ $json.date }}",
"period": "={{ new Date($json.date).format(\"yyyy-MM\") }}"
},
"schema": [
{
"id": "period",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "period",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "date",
"type": "string",
"display": true,
"required": false,
"displayName": "date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Property",
"type": "string",
"display": true,
"required": false,
"displayName": "Property",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "UP_FROM_UP",
"type": "string",
"display": true,
"required": false,
"displayName": "UP_FROM_UP",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "DOWN_FROM_DOWN",
"type": "string",
"display": true,
"required": false,
"displayName": "DOWN_FROM_DOWN",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "UP_FROM_DOWN",
"type": "string",
"display": true,
"required": false,
"displayName": "UP_FROM_DOWN",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "DOWN_FROM_UP",
"type": "string",
"display": true,
"required": false,
"displayName": "DOWN_FROM_UP",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": []
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "name",
"value": "={{ $('Calculate Status').item.json.Property }}"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1t2RT3lxyxXj3X1y6klWvyhEJEazpkT3Hpi2ttEJRVT4",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1t2RT3lxyxXj3X1y6klWvyhEJEazpkT3Hpi2ttEJRVT4/edit?usp=drivesdk",
"cachedResultName": "n8n uptime"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "XHvC7jIRR8A2TlUl",
"name": "Google Sheets account"
}
},
"typeVersion": 4.3
},
{
"id": "fe97a18b-902c-4fab-bf73-69b5b9e41a11",
"name": "更新站点状态",
"type": "n8n-nodes-base.googleSheets",
"position": [
3100,
520
],
"parameters": {
"columns": {
"value": {
"Status": "={{ $json[\"DOWN_FROM_UP\"] || $json[\"DOWN_FROM_DOWN\"] ? 'DOWN' : 'UP' }}",
"Property": "={{ $json.Property }}"
},
"schema": [
{
"id": "Property",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Property",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Status",
"type": "string",
"display": true,
"required": false,
"displayName": "Status",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"Property"
]
},
"options": {},
"operation": "appendOrUpdate",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1t2RT3lxyxXj3X1y6klWvyhEJEazpkT3Hpi2ttEJRVT4/edit#gid=0",
"cachedResultName": "dashboard"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1t2RT3lxyxXj3X1y6klWvyhEJEazpkT3Hpi2ttEJRVT4",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1t2RT3lxyxXj3X1y6klWvyhEJEazpkT3Hpi2ttEJRVT4/edit?usp=drivesdk",
"cachedResultName": "n8n uptime"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "XHvC7jIRR8A2TlUl",
"name": "Google Sheets account"
}
},
"typeVersion": 4.3
},
{
"id": "b37537d1-eedf-446e-a5ed-2ef7388fd7bc",
"name": "执行站点测试",
"type": "n8n-nodes-base.httpRequest",
"position": [
2207,
460
],
"parameters": {
"url": "={{ $json.Property }}",
"options": {
"response": {
"response": {
"neverError": true,
"fullResponse": true
}
}
},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{}
]
}
},
"typeVersion": 4.2
},
{
"id": "22efcca8-81a8-4128-a03f-efd394e41977",
"name": "对于每个站点...",
"type": "n8n-nodes-base.splitInBatches",
"position": [
2007,
460
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "b74d0b2c-8b08-42fe-a78f-103d4ea3b60f",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
1375.3365733151754,
160
],
"parameters": {
"color": 7,
"width": 533.3167991131336,
"height": 451.46281790887826,
"content": "## 1. 设置计划"
},
"typeVersion": 1
},
{
"id": "6c570ff2-aa08-4458-b2da-7632d516c4e3",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
1940,
247.83581204342858
],
"parameters": {
"color": 7,
"width": 596.6620781418152,
"height": 464.2968162619932,
"content": "## 2. 执行站点检查"
},
"typeVersion": 1
},
{
"id": "d1f67650-1409-43b1-b197-0e5a821d8b6f",
"name": "便利贴5",
"type": "n8n-nodes-base.stickyNote",
"position": [
2580,
117.20168629145996
],
"parameters": {
"color": 7,
"width": 720.3351531809235,
"height": 600.2604061412927,
"content": "## 3. 发送警报和记录结果"
},
"typeVersion": 1
},
{
"id": "244291de-7ce1-48c9-9d7a-c04fc7d069ab",
"name": "状态路由器",
"type": "n8n-nodes-base.switch",
"position": [
2640,
520
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "UP_FROM_UP",
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.UP_FROM_UP }}",
"rightValue": 200
}
]
},
"renameOutput": true
},
{
"outputKey": "UP_FROM_DOWN",
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "f50ae8d6-4359-4163-aedb-fddf100ad676",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.UP_FROM_DOWN }}",
"rightValue": 200
}
]
},
"renameOutput": true
},
{
"outputKey": "DOWN_FROM_DOWN",
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "417e93d8-08b7-468d-a3bb-f0d395b3026a",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.DOWN_FROM_DOWN }}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "DOWN_FROM_UP",
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "7191e7cb-f2e1-4288-aa68-21f6efefafc5",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.DOWN_FROM_UP }}",
"rightValue": ""
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3
},
{
"id": "a2a683fa-1fa5-4595-856a-de4f717eadf0",
"name": "便签 6",
"type": "n8n-nodes-base.stickyNote",
"position": [
1063.07390978683,
160
],
"parameters": {
"width": 276.590892958905,
"height": 299.942498076894,
"content": "## 试试看!"
},
"typeVersion": 1
},
{
"id": "704ce21f-6b96-4dc5-a27f-fca4b326efd1",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
1620,
380
],
"parameters": {
"width": 262.6069985025353,
"height": 379.4991553144906,
"content": ""
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"Get Sites": {
"main": [
[
{
"node": "For Each Site...",
"type": "main",
"index": 0
}
]
]
},
"Status Router": {
"main": [
[
{
"node": "Log Uptime Event",
"type": "main",
"index": 0
}
],
[
{
"node": "Send Email Alert",
"type": "main",
"index": 0
},
{
"node": "Log Uptime Event",
"type": "main",
"index": 0
}
],
[
{
"node": "Log Uptime Event",
"type": "main",
"index": 0
},
{
"node": "Send Email Alert",
"type": "main",
"index": 0
}
],
[
{
"node": "Send Email Alert",
"type": "main",
"index": 0
},
{
"node": "Log Uptime Event",
"type": "main",
"index": 0
}
]
]
},
"Calculate Status": {
"main": [
[
{
"node": "Status Router",
"type": "main",
"index": 0
}
]
]
},
"For Each Site...": {
"main": [
null,
[
{
"node": "Perform Site Test",
"type": "main",
"index": 0
}
]
]
},
"Log Uptime Event": {
"main": [
[
{
"node": "Update Site Status",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Get Sites",
"type": "main",
"index": 0
}
]
]
},
"Send Email Alert": {
"main": [
[
{
"node": "Send Chat Alert",
"type": "main",
"index": 0
}
]
]
},
"Perform Site Test": {
"main": [
[
{
"node": "Calculate Status",
"type": "main",
"index": 0
}
]
]
},
"Update Site Status": {
"main": [
[
{
"node": "For Each Site...",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 开发运维, IT 运维
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
审核Google Drive文件权限以进行访问控制管理
审核Google Drive文件权限以进行访问控制管理
Set
Gmail
Filter
+8
19 节点Jimleuk
IT 运维
使用AI汇总Slack频道活动生成周报
使用AI汇总Slack频道活动生成周报
If
Set
Code
+13
47 节点Jimleuk
其他
网页变更检测与Google套件哈希追踪告警
网页变更检测与Google套件哈希追踪告警
Set
Html
Gmail
+8
14 节点Jimleuk
其他
自动化 Discord 垃圾信息审核
结合 AI 和人机协作的自动化 Discord 垃圾信息审核
If
Set
Code
+14
30 节点Jimleuk
人工智能
模板 - SSL到期警报系统
使用Google表格和多渠道警报监控SSL证书到期
Ntfy
Gmail
Switch
+5
21 节点Jesse Davids
开发运维
使用Langchain代码节点追踪每个客户的LLM令牌成本
使用Langchain代码节点追踪每个客户的LLM令牌成本
Set
Form
Gmail
+10
20 节点Jimleuk
工程
工作流信息
难度等级
中级
节点数量15
分类2
节点类型9
作者
Jimleuk
@jimleukFreelance consultant based in the UK specialising in AI-powered automations. I work with select clients tackling their most challenging projects. For business enquiries, send me an email at hello@jimle.uk LinkedIn: https://www.linkedin.com/in/jimleuk/ X/Twitter: https://x.com/jimle_uk
外部链接
在 n8n.io 查看 →
分享此工作流