Skip to main content

Kubernetes RCA and alerting using Gemini, Loki, Prometheus, Slack

Workflow preview

Workflow preview
100%
Kubernetes RCA and alerting using Gemini, Loki, Prometheus, Slack preview
Open on n8n.io

Important notice

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

1. Workflow Overview

Summary This n8n workflow automates Kubernetes root cause analysis (RCA) and incident alerting by integrating with Loki, Prometheus, and Slack. It streamlines log collection, cluster health monitor...

Best for

  • AI Summarization automation workflows
  • Multimodal AI automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.scheduletrigger, n8n-nodes-base.httprequest, n8n-nodes-base.code, n8n-nodes-base.ssh, n8n-nodes-base.merge, n8n-nodes-base.if, 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 John Pranay Kumar Reddy.

Original n8n.io source

1.1 Workflow description

Title
Kubernetes RCA and alerting using Gemini, Loki, Prometheus, Slack
Workflow name
Kubernetes RCA and alerting using Gemini, Loki, Prometheus, Slack

Summary

This n8n workflow automates Kubernetes root cause analysis (RCA) and incident alerting by integrating with Loki, Prometheus, and Slack. It streamlines log collection, cluster health monitoring, and AI-driven RCA with Gemini, saving DevOps teams hours of manual troubleshooting. Designed for production-grade Kubernetes environments, this plug-and-play workflow delivers actionable insights directly to your Slack channels.

Who’s It For

πŸ› οΈ DevOps Engineers automating Kubernetes monitoring and incident response.

πŸ” Site Reliability Engineers (SREs) aiming to reduce mean time to resolution (MTTR).

πŸš€ Teams using n8n, Slack, Loki, and Prometheus for observability and automation.

What It Does

  • Pulls logs from Loki, filtering for critical errors.
  • Monitors cluster health, checking pending, not ready, or restarting pods.
  • Fetches Prometheus metrics for nodes, namespaces, and services.
  • Generates AI-driven RCA using Google Gemini to analyze logs and metrics.
  • Sends formatted Slack alerts with deduplication and batching for readability.
  • Tracks pod lifecycle events, including crashloop states and restarts.

How It Works

  • Log Collection: The workflow uses an n8n HTTP Request node to pull logs from Loki, filtering for critical errors.
  • Cluster Monitoring: A Kubernetes SSH node checks pod states (terminated or running). If terminated ignore those pods for RCA.
  • Metrics Fetching: Prometheus metrics are retrieved via HTTP Request for nodes and services.
  • RCA Generation: Logs and metrics are merged into structured prompts for Google Gemini AI to produce actionable RCA insights.
  • Kubernetes Enrichment: RCA from Gemini will goes to this node and enriches with Kubernetes documentation and provide the documentation links in RCA
  • Slack Notifications: Alerts are batched, deduplicated, and sent to Slack with clear formatting.

How to Set Up

  • Import the Workflow: Download the .json file and import it into your n8n instance.

Configure Credentials:

  • Add your Loki, Prometheus, and Slack API credentials in the respective nodes (use n8n Credentials Manager if required).
  • Set up Google Gemini AI credentials for RCA generation.
  • Test the Workflow: Run the workflow manually to ensure logs, metrics, and alerts are processed correctly.
  • Schedule Execution: Use n8n’s Schedule Trigger to run the workflow at desired intervals (e.g., every 5 minutes).

Requirements

🌐 n8 K8s node installed (self-hosted only, see n8n documentation).

πŸ”‘ Access to Kubernetes clusters and API.

πŸ“Š Loki and Prometheus set up for log and metrics collection.

πŸ’¬ Slack workspace with webhook access for notifications.

πŸ€– Google Gemini AI API key for RCA generation.

How to Customize the Workflow

  • Adjust Filters: Modify the Loki query in the HTTP Request node to focus on specific error patterns.
  • Change Alert Frequency: Update the Schedule Trigger node for different intervals.
  • Add More Metrics: Extend the Prometheus node to include additional metrics like CPU or memory usage.
  • Customize Slack Alerts: Edit the Slack node to change message formatting or add more channels.
  • Enhance RCA: Adjust the Gemini AI prompt in the Set Fields node for more specific insights.

πŸ—‚οΈ Category

DevOps / Monitoring & Observability / Kubernetes/ AI

🏷️ Tags

kubernetes, prometheus, slack, alerting, sre, ops, kube-state-metrics, Gemini, AI

Slack Output

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 Trigger1

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

Block 2 - Google Gemini1

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

Block 3 - πŸ“€ Send Alerts to Slack

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

Block 4 - Kubernetes Documentation

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

Block 5 - Loki

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

Block 6 - Formatting the Output to send to Slack

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

Block 7 - SSH1

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

Block 8 - PromQL: Current endpoints

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

Block 9 - PromQL: Endpoints 5m ago

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

Block 10 - Merge

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 11 - Pods Not Ready

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

Block 12 - Pod Restart Spike (last 5m)

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

Block 13 - Map Prometheus results into namespace/service

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

Block 14 - Map Prometheus results into namespace/service1

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

Block 15 - Merge2

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 16 - Batch

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

Block 17 - Pods Pending

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

Block 18 - Pods Pending State

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

Block 19 - Endpoints

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

Block 20 - If(Excludes Pods which are terminated already)

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

Block 21 - Loki Error Logs

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

Block 22 - Pods Not Ready State

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

Block 23 - Termination State

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

Block 24 - CrashLoopBackOff

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

Showing the first 24 of 36 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Kubernetes RCA and alerting using Gemini, Loki, Prometheus, Slack
Complexity advanced
Nodes 36
Categories AI Summarization, Multimodal AI
Author John Pranay Kumar Reddy
Published 27 Aug 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/7953/7953.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 Kubernetes RCA and alerting using Gemini, Loki, Prometheus, Slack do?

Summary This n8n workflow automates Kubernetes root cause analysis (RCA) and incident alerting by integrating with Loki, Prometheus, and Slack. It streamlines log collection, cluster health monitor...

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 AI Summarization, Multimodal AI use case.