Skip to main content

Monitor security logs for failed login attempts with Slack alerts

Workflow preview

Workflow preview
100%
Monitor security logs for failed login attempts with Slack alerts preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

How It Works: The 5 Node Anomaly Detection Flow This workflow efficiently processes logs to detect anomalies. 1. Scheduled Check (Cron Node): This is the primary trigger. It schedules the workflow ...

Best for

  • SecOps automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

n8n-nodes-base.scheduletrigger, n8n-nodes-base.httprequest, n8n-nodes-base.code, n8n-nodes-base.if, n8n-nodes-base.slack, n8n-nodes-base.stickynote

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Marth.

Original n8n.io source

1.1 Workflow description

Title
Monitor security logs for failed login attempts with Slack alerts
Workflow name
Monitor security logs for failed login attempts with Slack alerts

How It Works: The 5-Node Anomaly Detection Flow

This workflow efficiently processes logs to detect anomalies.

  1. Scheduled Check (Cron Node): This is the primary trigger. It schedules the workflow to run at a defined interval (e.g., every 15 minutes), ensuring logs are routinely scanned for suspicious activity.

  2. Fetch Logs (HTTP Request Node): This node is responsible for retrieving logs from an external source. It sends a request to your log API endpoint to get a batch of the most recent logs.

  3. Count Failed Logins (Code Node): This is the core of the detection logic. The JavaScript code filters the logs for a specific event ("login_failure"), counts the total, and identifies unique IPs involved. This information is then passed to the next node.

  4. Failed Logins > Threshold? (If Node): This node serves as the final filter. It checks if the number of failed logins exceeds a threshold you set (e.g., more than 5 attempts). If it does, the workflow is routed to the notification node; if not, the workflow ends safely.

  5. Send Anomaly Alert (Slack Node): This node sends an alert to your team if an anomaly is detected. The Slack message includes a summary of the anomaly, such as the number of failed attempts and the IPs involved, enabling a swift response.


How to Set Up

Implementing this essential log anomaly detector in your n8n instance is quick and straightforward.

  1. Prepare Your Credentials & API:

    • Log API: Make sure you have an API endpoint or a way to get logs from your system (e.g., a server, CMS, or application). The logs should be in JSON format, and you'll need any necessary API keys or tokens.
    • Slack Credential: Set up a Slack credential in n8n and get the Channel ID of your security alert channel (e.g., #security-alerts).
  2. Import the Workflow JSON:

    • Create a new workflow in n8n and choose "Import from JSON."
    • Paste the JSON code (which was provided in a previous response).
  3. Configure the Nodes:

    • Scheduled Check (Cron): Set the schedule according to your preference (e.g., every 15 minutes).
    • Fetch Logs (HTTP Request): Update the URL and header/authentication to match your specific log API endpoint.
    • Count Failed Logins (Code): Verify that the JavaScript code matches your log's JSON format. You may need to adjust log.event === 'login_failure' if your log events use a different name.
    • Failed Logins > Threshold? (If): Adjust the threshold value (e.g., 5) based on your risk tolerance.
    • Send Anomaly Alert (Slack): Select your Slack credential and enter the correct Channel ID.
  4. Test and Activate:

    • Manual Test: Run the workflow manually to confirm it fetches logs and processes them correctly. You can temporarily lower the threshold to 0 to ensure the alert is triggered.
    • Verify Output: Check your Slack channel to confirm that alerts are formatted and sent correctly.
    • Activate: Once you're confident in its function, activate the workflow. n8n will now automatically monitor your logs on the schedule you set.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Schedule Trigger

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.2

Block 2 - Fetch Logs

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 3 - Count Failed Logins

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 4 - Failed Logins > Threshold?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 5 - Send Anomaly Alert

Type / Role
n8n-nodes-base.slack - slack
Config choices
Version 2.3

Block 6 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Monitor security logs for failed login attempts with Slack alerts
Complexity intermediate
Nodes 7
Categories SecOps
Author Marth
Published 03 Aug 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/6922/6922.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Monitor security logs for failed login attempts with Slack alerts do?

How It Works: The 5 Node Anomaly Detection Flow This workflow efficiently processes logs to detect anomalies. 1. Scheduled Check (Cron Node): This is the primary trigger. It schedules the workflow ...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your SecOps use case.