带有Slack警报和自动错误工单创建的错误日志监控器
高级
这是一个DevOps领域的自动化工作流,包含 20 个节点。主要使用 If, Set, Ssh, Code, Jira 等节点。 带有SSH、Slack警报和Jira工单创建的错误日志监控器
前置要求
- •Slack Bot Token 或 Webhook URL
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "VbL8CupBzmcRolP4",
"meta": {
"instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281",
"templateCredsSetupCompleted": true
},
"name": "带有Slack警报和自动错误工单创建的错误日志监控器",
"tags": [],
"nodes": [
{
"id": "44f0eba7-b92a-47f0-a7b0-c90eb5d9e8f0",
"name": "手动触发器",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-480,
60
],
"parameters": {},
"typeVersion": 1
},
{
"id": "19a920cb-28da-4388-80f2-a1b7bd87badb",
"name": "设置配置",
"type": "n8n-nodes-base.set",
"position": [
-260,
160
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "cf9f1b38-541c-4311-9fea-c66d7fd39473",
"name": "读取错误日志",
"type": "n8n-nodes-base.ssh",
"position": [
-40,
160
],
"parameters": {
"command": "tail -n 50 /var/log/application/error.log | grep -E '(CRITICAL|ERROR|FATAL)' || echo 'No critical errors found'",
"authentication": "privateKey"
},
"credentials": {
"sshPrivateKey": {
"id": "ilPh8oO4GfSlc0Qy",
"name": "SSH Password account - test "
}
},
"typeVersion": 1
},
{
"id": "87962f71-2a7b-4913-b660-c3b1d7ee328d",
"name": "解析日志",
"type": "n8n-nodes-base.code",
"position": [
400,
160
],
"parameters": {
"jsCode": "const logOutput = $input.first().json.stdout || '';\nconst lines = logOutput.split('\\n').filter(line => line.trim() !== '' && line !== 'No critical errors found');\n\nconst errors = [];\n\nlines.forEach((line, index) => {\n let errorLevel = 'ERROR';\n \n if (line.includes('CRITICAL') || line.includes('FATAL')) {\n errorLevel = 'CRITICAL';\n }\n \n const timestamp = new Date().toISOString();\n const errorId = `ERR-${Date.now()}-${index}`;\n \n errors.push({\n id: errorId,\n level: errorLevel,\n message: line.trim(),\n timestamp: timestamp,\n raw_log: line\n });\n});\n\nreturn errors.map(error => ({ json: error }));"
},
"typeVersion": 2
},
{
"id": "093e59c5-8c25-4c70-9f61-418cfded5f40",
"name": "如果是关键错误",
"type": "n8n-nodes-base.if",
"position": [
620,
160
],
"parameters": {
"options": {},
"conditions": {
"options": {
"leftValue": "={{ $json.level }}",
"operation": "equal",
"rightValue": "CRITICAL"
}
}
},
"typeVersion": 2
},
{
"id": "0ca2c626-4dd7-42f8-837d-559c9df7657b",
"name": "发送Slack警报",
"type": "n8n-nodes-base.slack",
"position": [
840,
-180
],
"webhookId": "a6dc2a87-e06c-463e-b63c-c08f8bf457ca",
"parameters": {
"text": "🚨 CRITICAL ERROR DETECTED",
"select": "channel",
"channelId": {
"__rl": true,
"mode": "id",
"value": "C0987654"
},
"otherOptions": {}
},
"credentials": {
"slackApi": {
"id": "MQ0fgwuS8AzfwFvy",
"name": "Slack account - test "
}
},
"typeVersion": 2
},
{
"id": "05e1b571-702b-4744-a3b7-38300058e3ff",
"name": "创建 Jira 工单",
"type": "n8n-nodes-base.jira",
"position": [
840,
160
],
"parameters": {
"project": {
"mode": "name",
"value": "BUG"
},
"summary": "Critical Error: {{ $json.id }}",
"issueType": {
"mode": "name",
"value": "Bug"
},
"additionalFields": {
"labels": [
"auto-generated",
"critical-error"
],
"priority": {
"mode": "name",
"value": "Highest"
},
"description": "**Error Details:**\\n\\nError ID: {{ $json.id }}\\nLevel: {{ $json.level }}\\nTimestamp: {{ $json.timestamp }}\\n\\n**Error Message:**\\n```\\n{{ $json.message }}\\n```\\n\\n**Raw Log:**\\n```\\n{{ $json.raw_log }}\\n```\\n\\n*This ticket was automatically created by the Error Monitoring System.*"
}
},
"credentials": {
"jiraSoftwareCloudApi": {
"id": "cP7JyAE1RB0zcBon",
"name": "Jira SW Cloud - test"
}
},
"typeVersion": 1
},
{
"id": "0b13473e-63de-4874-8d9e-843cc8e51c1d",
"name": "发送非关键警报",
"type": "n8n-nodes-base.slack",
"position": [
860,
520
],
"webhookId": "7fdc3628-087e-4fc3-ba38-56c54461b293",
"parameters": {
"text": "⚠️ Error Detected: {{ $json.level }}",
"select": "channel",
"channelId": {
"__rl": true,
"mode": "id",
"value": "C098765"
},
"otherOptions": {}
},
"credentials": {
"slackApi": {
"id": "MQ0fgwuS8AzfwFvy",
"name": "Slack account - test "
}
},
"typeVersion": 2
},
{
"id": "4374ae68-f2a2-46f1-82e9-a98e3dc7886f",
"name": "等待所有日志",
"type": "n8n-nodes-base.wait",
"position": [
180,
160
],
"webhookId": "fdde8463-2899-4169-891b-7a5df07b4f34",
"parameters": {},
"typeVersion": 1.1
},
{
"id": "d90c28f1-6013-4e04-b676-7f8d831ab1d3",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-280,
40
],
"parameters": {
"color": 5,
"width": 160,
"height": 280,
"content": "配置基本参数"
},
"typeVersion": 1
},
{
"id": "7e3948e4-5ac8-4a98-a45d-5c8097208b46",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-500,
-20
],
"parameters": {
"color": 4,
"width": 150,
"height": 220,
"content": "用于测试"
},
"typeVersion": 1
},
{
"id": "702b64fb-c7b9-44b6-9d5f-d3597a2d366b",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-500,
300
],
"parameters": {
"color": 3,
"width": 150,
"height": 220,
"content": "每5分钟自动运行一次"
},
"typeVersion": 1
},
{
"id": "0ba8b489-3f92-4d0a-93f7-121aaca95771",
"name": "每5分钟调度",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-480,
380
],
"parameters": {
"rule": {
"interval": [
{
"field": "minutes"
}
]
}
},
"typeVersion": 1
},
{
"id": "2250de6b-468a-49bb-a6ef-76be482fe3a9",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
360,
40
],
"parameters": {
"color": 3,
"width": 160,
"height": 280,
"content": "用于解析和分类错误的JavaScript代码"
},
"typeVersion": 1
},
{
"id": "2231a875-1367-47d0-aab0-7a4fcc03fe5c",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
140,
40
],
"parameters": {
"color": 6,
"width": 160,
"height": 280,
"content": "等待所有错误日志读取"
},
"typeVersion": 1
},
{
"id": "f3c58543-431e-40aa-9e30-f5bc0a181c0d",
"name": "便签5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-60,
40
],
"parameters": {
"width": 160,
"height": 280,
"content": "SSH连接到服务器并读取错误日志"
},
"typeVersion": 1
},
{
"id": "8e5766d8-d40b-4867-8a17-88fdf9a40b29",
"name": "便签6",
"type": "n8n-nodes-base.stickyNote",
"position": [
840,
400
],
"parameters": {
"color": 5,
"width": 160,
"height": 260,
"content": "为非关键错误发送简单警报"
},
"typeVersion": 1
},
{
"id": "c71bc4f9-a96e-4b08-beba-5b3c3bce86c7",
"name": "便签7",
"type": "n8n-nodes-base.stickyNote",
"position": [
820,
40
],
"parameters": {
"width": 160,
"height": 260,
"content": "为关键错误自动创建错误工单"
},
"typeVersion": 1
},
{
"id": "fa119483-66e9-40e5-9e50-4837807f50e0",
"name": "便签8",
"type": "n8n-nodes-base.stickyNote",
"position": [
800,
-300
],
"parameters": {
"color": 6,
"width": 160,
"height": 280,
"content": "为关键错误发送详细警报"
},
"typeVersion": 1
},
{
"id": "7f07dd84-a237-4b62-9e32-7b431c844152",
"name": "便签9",
"type": "n8n-nodes-base.stickyNote",
"position": [
580,
40
],
"parameters": {
"color": 4,
"width": 160,
"height": 280,
"content": "从常规错误中筛选关键错误"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "9ee70159-d6b0-4271-bda9-3ab79401d38e",
"connections": {
"Parse Logs": {
"main": [
[
{
"node": "IF Critical Error",
"type": "main",
"index": 0
}
]
]
},
"Set Config": {
"main": [
[
{
"node": "Read Error Logs",
"type": "main",
"index": 0
}
]
]
},
"Manual Trigger": {
"main": [
[
{
"node": "Set Config",
"type": "main",
"index": 0
}
]
]
},
"Read Error Logs": {
"main": [
[
{
"node": "Wait For All Logs",
"type": "main",
"index": 0
}
]
]
},
"Send Slack Alert": {
"main": [
[]
]
},
"IF Critical Error": {
"main": [
[
{
"node": "Send Slack Alert",
"type": "main",
"index": 0
},
{
"node": "Create Jira Ticket",
"type": "main",
"index": 0
}
],
[
{
"node": "Send Non-Critical Alert",
"type": "main",
"index": 0
}
]
]
},
"Wait For All Logs": {
"main": [
[
{
"node": "Parse Logs",
"type": "main",
"index": 0
}
]
]
},
"Create Jira Ticket": {
"main": [
[]
]
},
"Schedule Every 5min": {
"main": [
[
{
"node": "Set Config",
"type": "main",
"index": 0
}
]
]
},
"Send Non-Critical Alert": {
"main": [
[]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 开发运维
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
n8n工作流自动备份到按用户名组织的GitLab
n8n工作流自动备份到按用户名组织的GitLab
If
N8n
Set
+7
15 节点Oneclick AI Squad
开发运维
自动化API正常运行时间监控与即时停机警报
API正常运行时间监控,含WhatsApp警报和Google表格管理
If
Code
Wait
+6
17 节点Oneclick AI Squad
开发运维
在短短10秒内自动化PostgreSQL和MySQL设置、创建和删除
在Linux服务器上自动化PostgreSQL和MySQL数据库管理
If
Set
Ssh
+2
15 节点Oneclick AI Squad
开发运维
10秒内在Linux服务器上全自动完成DevOps基础设施搭建
使用Docker、K8s、Jenkins和Grafana实现Linux服务器的DevOps基础设施自动化
Set
Ssh
Wait
+2
13 节点Oneclick AI Squad
开发运维
事件管理工作流
通过Jira、Slack、Google Sheets和Drive自动化事件响应
If
Set
Code
+8
23 节点Rahul Joshi
开发运维
绩效评估调度与提醒
使用Google Sheets、日历、邮件和Slack自动化绩效评估流程
If
Set
Code
+7
16 节点Oneclick AI Squad
人力资源
工作流信息
难度等级
高级
节点数量20
分类1
节点类型10
作者
Oneclick AI Squad
@oneclick-aiThe AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.
外部链接
在 n8n.io 查看 →
分享此工作流