n8n error logging with email rate limit Postgres
This n8n workflow logs every error to PostgreSQL but sends at most one alert email every five minutes. It is for teams whose scheduled jobs can fail in bursts and flood inboxes, who still want a full record of each error in a database.
What it does
An Error Trigger writes each event to a Postgres log table, then counts the rows from the last five minutes. If no recent alert went out, it sends a principal email, falls back to a second email server on failure and pushes a mobile notification through Pushover. A manual branch truncates the log table.
How to use it
Set it as the error workflow, or call it before your own error handling logic, and connect Postgres, SMTP and Pushover.
More in PostgreSQL and the n8n workflow library.
Full text
Front matter
name: Log errors and avoid sending too many emails
description: Triggered manually or by an app event. Connects Code, Condition, Email, Execute Workflow, PostgreSQL, Pushover. # Log errors and avoid sending too many emails ## Use case Most of the time, it’s necessary to log all errors that occur. However, in some cases, a scheduled task or service consuming excessive resources might trigger a surge of errors. To address this, we can log all errors but limit alerts to a maximum of one notification every 5 minutes. ## What this workflow does This workflow can be configured to receive error events, or you can integrate it **before your own error-handling logic.**
category: Automation
kind: Workflow
software: Code|Condition|Email|Execute Workflow|PostgreSQL|PushoverLog errors and avoid sending too many emails
Triggered manually or by an app event. Connects Code, Condition, Email, Execute Workflow, PostgreSQL, Pushover. # Log errors and avoid sending too many emails
Use case
Most of the time, it’s necessary to log all errors that occur. However, in some cases, a scheduled task or service consuming excessive resources might trigger a surge of errors.
To address this, we can log all errors but limit alerts to a maximum of one notification every 5 minutes.
What this workflow does
This workflow can be configured to receive error events, or you can integrate it before your own error-handling logic.
Steps
- Error Trigger (errorTrigger)
- Insert Log (postgres)
- Count for 5 minutes (postgres)
- Sticky Note (stickyNote)
- Principal E-Mail (emailSend)
- Fallback E-Mail (emailSend)
- Push mobile notification (pushover)
- Truncate Log Database (postgres)
- Sometimes... just cleanup (manualTrigger)
- Call this Sample - Prepend to your error catcher (executeWorkflow)
- See below to prepend this at your error handling (executeWorkflowTrigger)
- If there is no logs in 5 minutes (if)
- CleanUp execution. See below if you will prepend this workflow (code)
- Insert your error handling logic after this (noOp)
- Sticky Note1 (stickyNote)
- Sticky Note2 (stickyNote)
Import
Download the JSON from the GitHub source and import it in n8n (Workflows, Import from file).
Source and license
Source: https://github.com/Zie619/n8n-workflows/blob/main/Error/1777_Error_Postgres_Send_Triggered.md
Author: Zie619, n8n workflow collection. License: MIT.
Shown here with formatting for the web. Keep the author and license notice when you reuse it.
Related entries
There are more like this in the members library
The n8n workflow library holds 1,814 entries. Members can search all of them by meaning and read every one in full.