8
n8n 中文网amn8n.com

通过HTTP请求从任意工作流发送结构化日志到BetterStack

中级

这是一个Engineering, DevOps领域的自动化工作流,包含 8 个节点。主要使用 HttpRequest, ManualTrigger, ExecuteWorkflow, ExecuteWorkflowTrigger 等节点。 通过HTTP请求从任意工作流发送结构化日志到BetterStack

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "568298fde06d3db80a2eea77fe5bf45f0c7bb898dea20b769944e9ac7c6c5a80"
  },
  "nodes": [
    {
      "id": "72babb83-0530-4809-9f6f-d9afaf91fd59",
      "name": "发送日志到 BetterStack",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        80,
        140
      ],
      "parameters": {
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"message\":\"{{ $json.message }}\",\n  \"level\": \"{{ $json.level }}\"\n} ",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "NAa1bu8yteVhXxxV",
          "name": "Header Auth BetterStack"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "863b184b-05c0-47b7-82c1-166bdf25a32a",
      "name": "接收日志消息",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "notes": "from another workflow",
      "position": [
        -140,
        140
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "level"
            },
            {
              "name": "message"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 1.1
    },
    {
      "id": "e696b65e-5249-43b2-9a33-4e59fc616f21",
      "name": "测试工作流",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -260,
        -120
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "f7b51eae-4016-4072-9539-b66ea8646508",
      "name": "发送测试日志消息",
      "type": "n8n-nodes-base.executeWorkflow",
      "notes": "using workflow",
      "position": [
        -40,
        -120
      ],
      "parameters": {
        "options": {},
        "workflowId": {
          "__rl": true,
          "mode": "id",
          "value": "={{$workflow.id}}"
        },
        "workflowInputs": {
          "value": {
            "level": "error",
            "message": "This is a test log message"
          },
          "schema": [
            {
              "id": "level",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "level",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "message",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "message",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "notesInFlow": true,
      "typeVersion": 1.2
    },
    {
      "id": "72457cde-ea6f-406a-8d5e-70878114dd3e",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -440,
        60
      ],
      "parameters": {
        "width": 860,
        "height": 280,
        "content": "## 发送日志条目到 BetterStack"
      },
      "typeVersion": 1
    },
    {
      "id": "442976e5-1306-4c9b-a3e6-5693ae6d132c",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -440,
        -240
      ],
      "parameters": {
        "color": 7,
        "width": 660,
        "height": 280,
        "content": "## 演示"
      },
      "typeVersion": 1
    },
    {
      "id": "4175c168-1f59-4213-8bc4-a71dd62c3bd9",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        20,
        100
      ],
      "parameters": {
        "color": 3,
        "height": 200,
        "content": "### 编辑我"
      },
      "typeVersion": 1
    },
    {
      "id": "c69c7c62-f4b5-4b14-b6be-8e9f3b8a38cd",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -780,
        -240
      ],
      "parameters": {
        "color": 6,
        "width": 300,
        "height": 580,
        "content": "### 🧾 记录到 BetterStack"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Test workflow": {
      "main": [
        [
          {
            "node": "Send test log message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recieve log message": {
      "main": [
        [
          {
            "node": "Send Log to BetterStack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 工程, 开发运维

需要付费吗?

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

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

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

作者
Audun

Audun

@xqus

Transforming complexity into simplicity.

外部链接
在 n8n.io 查看

分享此工作流