Web Server Monitor.
工作流概述
这是一个包含7个节点的中等工作流,主要用于自动化处理各种任务。
工作流源代码
{
"id": "pcLi17oUJK9pSaee",
"meta": {
"instanceId": "10ac0d272b984a3e01d44645b4be41105d42352c9db9f4c0c7f5be7946b87d41",
"templateCredsSetupCompleted": true
},
"name": "Web Server Monitor.",
"tags": [],
"nodes": [
{
"id": "014e1202-3822-4d3f-817e-31f64c8bd5f5",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-680,
-440
],
"parameters": {
"width": 560,
"height": 540,
"content": "📘 Node Descriptions for Your Web Server Monitor Workflow
⏰ 1. Schedule Trigger
Triggers the workflow every minute to initiate regular checks on server availability.
📄 2. Web Servers List (Google Sheets)
Fetches a list of server hostnames or IP addresses from a Google Sheet.
Each row is treated as one server. This makes server management easy — no need to edit the workflow to add/remove servers.
🌐 3. Server Alive Check (HTTP)
Sends an HTTP GET request to each server (e.g., http://your-server.com).
If the request fails, the error path is triggered.
📝 4. Web Server Alive Log (Google Sheets)
Logs successful server checks into a separate Sheet with a timestamp.
This log helps track uptime history, verify server health, and generate availability reports.
🚨📧 5. Server Down Notification (Gmail)
Sends an alert email if a server does not respond or returns an error.
Includes the server address and the timestamp of failure.
📝 6. Web Server Down Log (Google Sheets)
Logs the failed server checks into another Sheet with a timestamp.
Useful for uptime reporting, debugging, and audit tracking.
"
},
"typeVersion": 1
},
{
"id": "94a3454c-69bd-4a5d-b169-8f3772a41321",
"name": "Schedule Trigger",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
0,
0
],
"parameters": {
"rule": {
"interval": [
{
"field": "minutes",
"minutesInterval": 1
}
]
}
},
"typeVersion": 1.2
},
{
"id": "f92fcadf-0b13-42ac-abed-aaf169d0ed76",
"name": "Server-Monitor",
"type": "n8n-nodes-base.googleSheets",
"position": [
220,
0
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": 524060827,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OiwBkf3bs3tcfi5cAIrOl_GrXw2EfQLdcPbh6SaBFKQ/edit#gid=524060827",
"cachedResultName": "Server_List"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1OiwBkf3bs3tcfi5cAIrOl_GrXw2EfQLdcPbh6SaBFKQ",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OiwBkf3bs3tcfi5cAIrOl_GrXw2EfQLdcPbh6SaBFKQ/edit?usp=drivesdk",
"cachedResultName": "Server-Monitor"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "8cXGgTelVK5DewVr",
"name": "Google Sheets account"
}
},
"typeVersion": 4.5
},
{
"id": "c168a1f9-1f3f-40b8-95d0-51f6259d8096",
"name": "HTTP Request",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueErrorOutput",
"position": [
440,
0
],
"parameters": {
"url": "=http://{{ $json.Server }}",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "0ac82373-6958-4de9-8cf7-94b0005197ff",
"name": "Server_Status_Alive",
"type": "n8n-nodes-base.googleSheets",
"position": [
660,
-180
],
"parameters": {
"columns": {
"value": {
"Status": "Alive",
"TimeStamp": "={{ $now.format('yyyy-MM-dd') }}",
"Server IP Address": "={{ $('Server-Monitor').item.json.Server }}"
},
"schema": [
{
"id": "TimeStamp",
"type": "string",
"display": true,
"required": false,
"displayName": "TimeStamp",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Server IP Address",
"type": "string",
"display": true,
"required": false,
"displayName": "Server IP Address",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Status",
"type": "string",
"display": true,
"required": false,
"displayName": "Status",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": 303958634,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OiwBkf3bs3tcfi5cAIrOl_GrXw2EfQLdcPbh6SaBFKQ/edit#gid=303958634",
"cachedResultName": "Server_Status_Alive"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1OiwBkf3bs3tcfi5cAIrOl_GrXw2EfQLdcPbh6SaBFKQ",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OiwBkf3bs3tcfi5cAIrOl_GrXw2EfQLdcPbh6SaBFKQ/edit?usp=drivesdk",
"cachedResultName": "Server-Monitor"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "8cXGgTelVK5DewVr",
"name": "Google Sheets account"
}
},
"typeVersion": 4.5
},
{
"id": "6dc31115-4ab6-44cf-ac4f-e2af82a5355e",
"name": "Gmail",
"type": "n8n-nodes-base.gmail",
"position": [
660,
100
],
"webhookId": "dec1def3-c858-4a43-b96e-2655d3fa3b77",
"parameters": {
"message": "=Hi Team,
At {{$now.format('yyyy-MM-dd HH:mm:ss')}}, the following server failed to respond to ping:
🔻 Server Down: {{ $json[\"Server\"] }}
Please investigate immediately to prevent service disruption.
Automated Monitoring System
",
"options": {},
"subject": "=🔻 Server Down: {{ $json[\"Server\"] }}: {{ $today.format('yyyy-MM-dd') }}"
},
"credentials": {
"gmailOAuth2": {
"id": "C1RVeb9JgdvkMkP4",
"name": "Gmail account 2"
}
},
"typeVersion": 2.1
},
{
"id": "10262115-57a2-4c4d-9a10-89f4f6ee4ed7",
"name": "Server_Status_Down",
"type": "n8n-nodes-base.googleSheets",
"position": [
880,
100
],
"parameters": {
"columns": {
"value": {
"Status": "Down",
"TimeStamp": "={{$now.format('yyyy-MM-dd HH:mm:ss')}}",
"Server IP Address": "={{ $('Server-Monitor').item.json.Server }}"
},
"schema": [
{
"id": "TimeStamp",
"type": "string",
"display": true,
"required": false,
"displayName": "TimeStamp",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Server IP Address",
"type": "string",
"display": true,
"required": false,
"displayName": "Server IP Address",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Status",
"type": "string",
"display": true,
"required": false,
"displayName": "Status",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OiwBkf3bs3tcfi5cAIrOl_GrXw2EfQLdcPbh6SaBFKQ/edit#gid=0",
"cachedResultName": "Server_Status_Down"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1OiwBkf3bs3tcfi5cAIrOl_GrXw2EfQLdcPbh6SaBFKQ",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OiwBkf3bs3tcfi5cAIrOl_GrXw2EfQLdcPbh6SaBFKQ/edit?usp=drivesdk",
"cachedResultName": "Server-Monitor"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "8cXGgTelVK5DewVr",
"name": "Google Sheets account"
}
},
"typeVersion": 4.5
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "21468219-4434-4a0c-a3c4-9068baccc3cc",
"connections": {
"Gmail": {
"main": [
[
{
"node": "Server_Status_Down",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request": {
"main": [
[
{
"node": "Server_Status_Alive",
"type": "main",
"index": 0
}
],
[
{
"node": "Gmail",
"type": "main",
"index": 0
}
]
]
},
"Server-Monitor": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Server-Monitor",
"type": "main",
"index": 0
}
]
]
}
}
}
功能特点
- 自动检测新邮件
- AI智能内容分析
- 自定义分类规则
- 批量处理能力
- 详细的处理日志
技术分析
节点类型及作用
- Stickynote
- Scheduletrigger
- Googlesheets
- Httprequest
- Gmail
复杂度评估
配置难度:
维护难度:
扩展性:
实施指南
前置条件
- 有效的Gmail账户
- n8n平台访问权限
- Google API凭证
- AI分类服务订阅
配置步骤
- 在n8n中导入工作流JSON文件
- 配置Gmail节点的认证信息
- 设置AI分类器的API密钥
- 自定义分类规则和标签映射
- 测试工作流执行
- 配置定时触发器(可选)
关键参数
| 参数名称 | 默认值 | 说明 |
|---|---|---|
| maxEmails | 50 | 单次处理的最大邮件数量 |
| confidenceThreshold | 0.8 | 分类置信度阈值 |
| autoLabel | true | 是否自动添加标签 |
最佳实践
优化建议
- 定期更新AI分类模型以提高准确性
- 根据邮件量调整处理批次大小
- 设置合理的分类置信度阈值
- 定期清理过期的分类规则
安全注意事项
- 妥善保管API密钥和认证信息
- 限制工作流的访问权限
- 定期审查处理日志
- 启用双因素认证保护Gmail账户
性能优化
- 使用增量处理减少重复工作
- 缓存频繁访问的数据
- 并行处理多个邮件分类任务
- 监控系统资源使用情况
故障排除
常见问题
邮件未被正确分类
检查AI分类器的置信度阈值设置,适当降低阈值或更新训练数据。
Gmail认证失败
确认Google API凭证有效且具有正确的权限范围,重新进行OAuth授权。
调试技巧
- 启用详细日志记录查看每个步骤的执行情况
- 使用测试邮件验证分类逻辑
- 检查网络连接和API服务状态
- 逐步执行工作流定位问题节点
错误处理
工作流包含以下错误处理机制:
- 网络超时自动重试(最多3次)
- API错误记录和告警
- 处理失败邮件的隔离机制
- 异常情况下的回滚操作