Automate Error Logging and Alert Limits with n8n & Postgres

Struggling with error floods overwhelming your notifications? This n8n workflow logs all errors into a Postgres database while limiting alert emails to one every 5 minutes, preventing alert fatigue and ensuring important issues get noticed.
errorTrigger
postgres
if
+7
Workflow Identifier: 1977
NODES in Use: Error Trigger, Postgres, If, Email Send, Pushover, Manual Trigger, Code, Execute Workflow, Execute Workflow Trigger, Sticky Note

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What this workflow does

This workflow catches errors in your n8n automations and keeps a record in a Postgres database.

It limits sending alert emails so your inbox is not flooded.

You get detailed logs and only one alert email every 5 minutes, even if many errors happen.


How it works: Inputs → Processing → Output

Inputs

  • Error event from the n8n errorTrigger node.
  • Postgres table to store error logs.
  • Optional alert channels like email SMTP or Pushover.

Processing Steps

  • The errorTrigger node captures each error event.
  • The workflow inserts detailed error info into the Postgres “N8Err” table.
  • A Postgres query counts how many error records were created in the last 5 minutes.
  • An If node checks if the error count is zero or less, to avoid sending many alerts.
  • If allowed, alert nodes (e.g. email or push notifications) send warning messages.
  • A cleanup node can delete all logs for testing purposes only.

Output

  • Error logs saved permanently in your database.
  • Rate-limited alert emails or notifications, max once every 5 minutes.

Who should use this workflow

This fits users who run many n8n automations and want clear, useful error reports.

It stops alert emails from drowning you when lots of errors happen at once.

It works well for both self-host n8n users and cloud users with access to Postgres.


Tools and services used

  • n8n Automation Platform: To build and run the workflow.
  • Postgres database: Stores error logs with detailed info.
  • SMTP Email: Optional, to send alert emails.
  • Pushover API: Optional, to send push notifications.

Beginner step-by-step: How to use this workflow in production

Step 1: Download and import the workflow

  1. Find the Download button on this page to get the workflow JSON file.
  2. Open the n8n editor where automations are made.
  3. Click on “Import from File” and select the downloaded JSON to add the workflow.

Step 2: Configure credentials and settings

  1. Add your Postgres database credentials in n8n credential settings.
  2. If you want email alerts, add SMTP email credentials in n8n.
  3. Update table names, schema, emails, or channels inside nodes if different from defaults.

Step 3: Test the workflow

  1. Trigger an error in any automation you control.
  2. Check the Postgres table “N8Err” to see if error details appear.
  3. Confirm no flood of emails is sent if multiple errors happen quickly.

Step 4: Activate the workflow

  1. Turn on the workflow inside n8n editor to run automatically on error events.
  2. Monitor logs and alerts during early use to validate operation.

Customization ideas

  • Change the error alert interval in the Postgres count query from 5 minutes to your preferred time.
  • Enable and set up the email or push notification nodes for live alerts.
  • Add other alert channels like Slack or Microsoft Teams after the If node.
  • Use a Cron node to schedule regular cleanup of old logs if needed in testing environments.
  • Modify the Insert Log node SQL to save extra error info as needed.

Troubleshooting common issues

  • Postgres connection refused: Check database credentials and server status.
  • No logs after errors: Confirm the errorTrigger fires and the Insert Log node matches your DB schema.
  • Emails sent too often: Make sure the count query outputs correctly and the If node condition is set to <= 0.

Summary

✓ The workflow captures error events automatically.

✓ Every error is logged with details inside Postgres.

✓ Alert emails are limited to once every 5 minutes when many errors happen.

→ This avoids inbox flooding and reduces wasted time.

→ You get clear error data and calm notifications to improve automation reliability.

Frequently Asked Questions

No. The workflow uses Postgres-specific SQL queries and node settings. MySQL is not supported without adapting the queries and nodes.
It counts error records created in the last 5 minutes in Postgres. If the count is greater than zero, it skips sending new alert emails to avoid flooding.
Users must add Postgres database credentials, configure SMTP email credentials if using email alerts, and update any emails, table names, or IDs used in workflow nodes.
Yes. Users can add a Cron node to trigger the cleanup node regularly. However, log cleanup should be done carefully, especially in production.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free