Course/Chapter 9/4. Monitoring & Alerting
    advanced
    Chapter 9: Troubleshooting & Debugging

    4. Monitoring & Alerting

    Set up alerts for failed executions.

    15m Lesson 4 of 5

    Don't wait for users to report broken automations. Proactive monitoring ensures you catch and fix issues before they impact your business.

    Monitoring Layers

    1. Workflow-level: Error Trigger workflow catches all failures
    2. Instance-level: Health check endpoint monitoring
    3. Infrastructure-level: Docker/server resource monitoring
    4. Business-level: Track expected outcomes (e.g., "did the daily report send?")

    Error Trigger Workflow

    Create a special workflow with the "Error Trigger" node. It fires whenever ANY other workflow fails, giving you centralized error handling.

    Code Examples

    Slack Alert for Failed Workflows
    javascript
    // In your Error Trigger workflow:
    const error = $input.first().json;
    
    const slackMessage = {
      blocks: [
        {
          type: "header",
          text: { type: "plain_text", text: "🚨 Workflow Failed" }
        },
        {
          type: "section",
          fields: [
            { type: "mrkdwn", text: `*Workflow:*\n${error.workflow.name}` },
            { type: "mrkdwn", text: `*Node:*\n${error.execution.lastNodeExecuted}` },
            { type: "mrkdwn", text: `*Error:*\n${error.execution.error.message}` },
            { type: "mrkdwn", text: `*Time:*\n${new Date().toISOString()}` }
          ]
        },
        {
          type: "actions",
          elements: [{
            type: "button",
            text: { type: "plain_text", text: "View Execution" },
            url: `${$env.N8N_HOST}/execution/${error.execution.id}`
          }]
        }
      ]
    };
    
    return [{ json: slackMessage }];

    Pro Tips

    • 💡Create a dedicated "Error Handler" workflow that all production workflows report to
    • 💡Include the workflow name, error message, and execution URL in alert messages
    • 💡Set up a daily "heartbeat" check — if your critical workflows haven't run, something is wrong

    Comprehension Quiz

    Answer 2 of 2 correctly to unlock lesson completion.

    1. What does an Error Trigger workflow do?

    2. What is a "heartbeat" check?

    Pass the quiz above to unlock lesson completion