8
n8n 中文网amn8n.com

工作流错误日志记录与警报

中级

这是一个DevOps, Multimodal AI领域的自动化工作流,包含 7 个节点。主要使用 Gmail, ErrorTrigger, GoogleSheets 等节点。 使用Google Sheets和Gmail的工作流错误日志记录与警报系统

前置要求
  • Google 账号和 Gmail API 凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "d1786ab0d745a7498abf13a9c2cdabb1374c006e889b79eef64ce0386b8f8a41",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "d1657692-c5ab-4402-a0e7-3341303c3e36",
      "name": "错误触发器",
      "type": "n8n-nodes-base.errorTrigger",
      "position": [
        740,
        780
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "058c8a03-8d6c-4da6-9319-8615432a7c4b",
      "name": "Google Sheets - 创建错误日志",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1000,
        680
      ],
      "parameters": {
        "columns": {
          "value": {
            "Log": "={{ $json.execution.error.stack }}",
            "Node ID": "={{ $json.execution.id }}",
            "Node Name": "={{ $json.execution.lastNodeExecuted }}",
            "Timestamp": "={{ new Date($json.execution.error.timestamp).toISOString() }}\n",
            "Workflow ID": "={{ $json.workflow.id }}",
            "Execution Url": "={{ $json.execution.url }}",
            "Workflow Name": "={{ $json.workflow.name }}"
          },
          "schema": [
            {
              "id": "Workflow ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Workflow ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Workflow Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Workflow Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Node Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Node Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Node ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Node ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Execution Url",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Execution Url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Log",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Log",
              "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/1JprCxz5IRZzuiYs-NNkYLffQIkeTiC0sd-3CyrcOKV4/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1JprCxz5IRZzuiYs-NNkYLffQIkeTiC0sd-3CyrcOKV4",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1JprCxz5IRZzuiYs-NNkYLffQIkeTiC0sd-3CyrcOKV4/edit?usp=drivesdk",
          "cachedResultName": "n8n Logs"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "ypmzFxQFfAacuVVC",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "084b673e-350e-4d11-b64b-3b370a30ee1b",
      "name": "Gmail - 发送通知",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1000,
        900
      ],
      "webhookId": "65520aeb-1e34-46cc-8b09-637061212c81",
      "parameters": {
        "sendTo": "n8n_log_template@yopmail.com",
        "message": "=🚨 n8n Workflow Error Alert\n\n• Workflow Name: {{ $json.workflow.name }}\n• Node: {{ $json.execution.error.context.nodeCause }}\n• Error Type: {{ $json.execution.error.name }}\n• Message: {{ $json.execution.error.description }}\n• Execution ID: {{ $json.execution.id }}\n• View Execution: {{ $json.execution.url }}",
        "options": {},
        "subject": "=🚨 n8n Error in Workflow \"{{ $json.workflow.name }}\" (Node: {{ $json.execution.error.context.nodeCause }})",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "CeBpTZBQSAMKVKJY",
          "name": "Gmail account (Billy Email 2)"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "4c00fa5d-b7c0-40b0-80b9-4818af5d353c",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1060,
        1160
      ],
      "parameters": {
        "color": 4,
        "width": 380,
        "height": 760,
        "content": "# 👋 你好,我是 Billy"
      },
      "typeVersion": 1
    },
    {
      "id": "af4f6dfc-fe05-478b-85c4-a1739c5cc7dc",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        660
      ],
      "parameters": {
        "color": 4,
        "width": 440,
        "height": 420,
        "content": "## 需要设置"
      },
      "typeVersion": 1
    },
    {
      "id": "b27f0f44-ad40-468d-bacc-ac134162fb6c",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        1160
      ],
      "parameters": {
        "color": 4,
        "width": 780,
        "height": 300,
        "content": "## 🚨 n8n 错误记录到 Google Sheets 并发送 Gmail 警报"
      },
      "typeVersion": 1
    },
    {
      "id": "e4f15d86-4fb8-4b1e-b2eb-7112d0e9cd74",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        1500
      ],
      "parameters": {
        "color": 4,
        "width": 780,
        "height": 380,
        "content": "## 📋 工作流流程概览"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {
    "Error Trigger": [
      {
        "workflow": {
          "id": "Kgf1bwD0lN39RQDk",
          "name": "My workflow 115"
        },
        "execution": {
          "id": "142",
          "url": "https://n8n.nodemationhub.com/workflow/Kgf1bwD0lN39RQDk/executions/142",
          "mode": "trigger",
          "error": {
            "name": "ExpressionError",
            "tags": {},
            "level": "warning",
            "stack": "ExpressionError: Invalid input for 'Specialty' [item 0]\n    at validateValueAgainstSchema (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/node-execution-context/utils/validate-value-against-schema.js:120:15)\n    at ExecuteContext._getNodeParameter (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/node-execution-context/node-execution-context.js:235:85)\n    at ExecuteContext.getNodeParameter (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/node-execution-context/execute-context.js:39:93)\n    at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Airtable/v2/actions/record/create.operation.js:77:29)\n    at ExecuteContext.router (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Airtable/v2/actions/router.js:57:71)\n    at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Airtable/v2/AirtableV2.node.js:41:39)\n    at WorkflowExecute.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/workflow-execute.js:687:50)\n    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/workflow-execute.js:921:62\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/workflow-execute.js:1257:20",
            "context": {
              "runIndex": 0,
              "itemIndex": 0,
              "nodeCause": "Airtable1"
            },
            "message": "Invalid input for 'Specialty' [item 0]",
            "timestamp": 1750416545020,
            "description": "'Specialty' expects one of the following values: [General, Billing, Technical, Account] but we got '12'",
            "functionality": "regular"
          },
          "lastNodeExecuted": "Airtable1"
        }
      }
    ]
  },
  "connections": {
    "Error Trigger": {
      "main": [
        [
          {
            "node": "Gmail - Send Notification",
            "type": "main",
            "index": 0
          },
          {
            "node": "Google Sheets - Create Error Log",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 开发运维, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量7
分类2
节点类型4
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Billy Christi

Billy Christi

@billy

I build scalable automation systems with n8n to help businesses save time and cut costs. 💼 n8n expert available for new projects 📩 billychartanto@gmail.com

外部链接
在 n8n.io 查看

分享此工作流