Log Errors and Avoid Sending Too Many Emails (Error Logging and Email Frequency Control)

This workflow is designed to automatically capture and record system errors while controlling the frequency of error notifications through database statistics to avoid excessive email alerts. It saves error information to a Postgres database and supports flexible integration into existing processes. Additionally, the workflow provides an automatic cleanup feature for error logs, ensuring a tidy development environment. It is suitable for automated systems that require centralized management of errors and monitoring notifications, enhancing the efficiency and responsiveness of error handling.

Workflow Diagram
Log Errors and Avoid Sending Too Many Emails (Error Logging and Email Frequency Control) Workflow diagram

Workflow Name

Log Errors and Avoid Sending Too Many Emails (Error Logging and Email Frequency Control)

Key Features and Highlights

This workflow is designed to capture and log error events within a system while controlling the frequency of error notification emails through database statistics, preventing alert flooding caused by excessive errors. It supports saving detailed error information into a Postgres database and can be configured either as the primary error handler or integrated as a sub-workflow within existing error handling processes. Additionally, it offers automatic error log cleanup functionality to facilitate maintenance in development environments.

Core Problems Addressed

  • Automatically records all errors to ensure complete preservation of error information for subsequent troubleshooting.
  • Limits the frequency of error notification emails to prevent excessive alerts during error surges.
  • Supports flexible integration to adapt to various error handling strategies.
  • Provides an error log cleanup mechanism for development environments to maintain database hygiene.

Use Cases

  • Any automated process requiring centralized management and monitoring of system errors.
  • Business systems that need to avoid excessive alerts triggered by frequent errors within a short period.
  • Development and testing environments that require periodic error log cleanup.
  • As part of a large-scale automation system’s error handling chain to unify error log recording.

Main Workflow Steps

  1. Error Trigger: Capture error events occurring during workflow execution.
  2. Insert Log: Write error details—including error message, stack trace, triggering node, and calling URL—into a specified table in the Postgres database.
  3. Count for 5 Minutes: Query the number of errors recorded in the past 5 minutes.
  4. If There Are No Logs in 5 Minutes: Determine whether any errors have been logged in the last 5 minutes to decide if notifications should be sent.
  5. Insert Your Error Handling Logic After This: Reserved insertion point for user-defined error handling logic.
  6. CleanUp Execution: Clear execution status to ensure the workflow terminates properly.
  7. Sometimes... Just Cleanup + Truncate Log Database: Manual trigger to perform error log database cleanup operations.

In addition, the workflow includes optional email notification nodes (Principal E-Mail, Fallback E-Mail) and mobile push notification nodes (Push Mobile Notification), which can be enabled as needed to provide multi-channel error alerts.

Systems or Services Involved

  • Postgres Database (operated via Postgres nodes for error log recording and querying)
  • SMTP Email Service (email sending nodes for error notifications; nodes are disabled by default)
  • Pushover Push Service (mobile push notifications; nodes are disabled by default)

Target Users and Value

  • DevOps engineers and automation operations teams seeking efficient and controllable error monitoring and alerting within automated workflows.
  • Developers managing error logs during development and testing phases to avoid alert flooding and maintain a clean environment.
  • Enterprise IT managers aiming to reduce false alarms and improve response efficiency through centralized logging and intelligent alerting.
  • Any users of automated systems requiring stable error recording while preventing excessive email disturbances.

This workflow was designed by Davi Saranszky Mesquita. It comes with detailed documentation and example DDL scripts to facilitate quick deployment and customization according to user needs. By properly configuring the Postgres tables and email/push notification services, users can achieve efficient error management and alert throttling.