Log errors and avoid sending too many emails

For the n8n platform, this workflow logs all errors while limiting notifications to one every 5 minutes, preventing alert overload. It captures error details in a PostgreSQL database, ensuring efficient tracking and management of issues. Ideal for maintaining system performance without overwhelming users with frequent alerts.

7/8/2025
16 nodes
Complex
7you4otsaggetwjjemailcomplexerrortriggerpostgresqlsticky noteemailsendpushoverexecuteworkflowexecuteworkflowtriggernoopadvanceddatabasedatanotificationlogicconditional
Categories:
Data Processing & AnalysisCommunication & MessagingBusiness Process AutomationEmail TriggeredComplex Workflow
Integrations:
ErrorTriggerPostgreSQLSticky NoteEmailSendPushoverExecuteWorkflowExecuteWorkflowTriggerNoOp

Target Audience

This workflow is ideal for:
- Developers and Engineers: Those who need to monitor and log errors in their applications.
- System Administrators: Professionals managing systems that require error tracking and alerting.
- Product Owners: Individuals interested in maintaining application reliability and user experience.
- Data Analysts: Users who need to analyze error trends and system performance over time.

Problem Solved

This workflow addresses the challenge of excessive error notifications by logging all errors while limiting alert notifications to one every 5 minutes. This ensures that users are informed of significant issues without overwhelming them with repetitive alerts, thus improving productivity and focus on critical issues.

Workflow Steps

  • Error Trigger: The workflow starts when an error occurs in the application.
    2. Insert Log: The error details, including the URL, error message, stack trace, and execution context, are logged into a PostgreSQL database table named N8Err.
    3. Count for 5 Minutes: A query counts the number of errors logged in the last 5 minutes to determine if notifications should be sent.
    4. Conditional Check: If no errors are logged within the last 5 minutes, the workflow proceeds without sending notifications.
    5. Email Notifications: If errors exist, it sends an email alert to the specified recipients. The workflow is designed to send only one alert during the 5-minute window, preventing spamming.
    6. Push Notifications: Optionally, a mobile push notification can also be sent to alert users of the error.
    7. Cleanup: The workflow includes a cleanup step to truncate the log database, which is particularly useful in development environments.
  • Customization Guide

  • Adjust Email Recipients: Modify the toEmail fields in the email nodes to change the recipients of the error notifications.
    2. Change Database Table: Update the Insert Log node to log errors in a different database table if needed.
    3. Modify Alert Frequency: Adjust the Count for 5 Minutes node to change the frequency of the alerts by altering the time frame.
    4. Integrate Additional Notifications: Add more notification nodes (e.g., SMS, Slack) to expand the alerting mechanism.
    5. Error Handling Logic: Insert custom error handling logic in the designated section to tailor the response to specific application needs.