01.kubernetes
Alert Googlechats

🚨 Building a Production Kubernetes Alerting Pipeline β†’ Google Chat (No SaaS Required)

One of the biggest operational challenges isn't deploying Kubernetes...

It's knowing something is broken before your users do.

Recently, I built a lightweight production alerting pipeline for our Kubernetes cluster that delivers critical alerts directly to Google Chat in real time.

The best part?

βœ… No expensive third-party SaaS βœ… Fully self-hosted βœ… Lightweight βœ… Easy to extend


πŸ—οΈ Architecture

Application Metrics
        β”‚
        β–Ό
   Prometheus
        β”‚
        β–Ό
 Prometheus Rules
        β”‚
        β–Ό
 Alertmanager
        β”‚
        β–Ό
Python/Flask Bridge
        β”‚
        β–Ό
 Google Chat Space

Simple, reliable, and easy to maintain.


⚑ What We Monitor

Instead of alerting on everything (which quickly leads to alert fatigue), we focus on signals that actually matter.

🚨 HTTP Errors

  • 5xx Error Rate
  • 4xx Error Rate (excluding expected 401/404 responses)
  • Per-URI Error Ratio

πŸ“ˆ Application Health

  • High latency
  • Failed Jobs
  • Container waiting state
  • CrashLoopBackOff
  • Deployment replica mismatch
  • HPA reaching maximum replicas
  • Pod readiness failures

Only actionable alerts reach the team.


πŸ”₯ Prometheus Rules

The alerting logic is built using PromQL, calculating error percentages over a rolling five-minute window.

Example:

5xx Requests
───────────────  > 10%
Total Requests

Similarly,

  • 4xx error ratio
  • Per-URI error ratio
  • Kubernetes health alerts

are evaluated continuously.


🐍 Lightweight Google Chat Bridge

Rather than relying on external notification services, I built a tiny Python + Flask webhook bridge.

Its job is simple:

πŸ“¨ Receive alerts from Alertmanager

⬇️

🎨 Format them into readable messages

⬇️

πŸ’¬ Deliver them directly to Google Chat

Since the bridge is completely independent, alert rules can evolve without redeploying the notification service.


🎯 Alertmanager Strategy

A few design choices dramatically reduced unnecessary notifications.

βœ… Default receiver

Unmatched alerts are discarded instead of generating noise.


πŸ“¦ Intelligent Grouping

Alerts are grouped by:

  • Alert Name
  • Namespace

This keeps related events together instead of flooding the chat.


πŸ”•

Alert Inhibition

Critical alerts automatically suppress lower-severity alerts for the same workload.

Instead of receiving:

❌ Warning

❌ Info

❌ Critical

You only receive:

🚨 Critical


⏰ Smart Repeat Interval

Long-running incidents are reminded every 4 hours, avoiding notification spam while keeping important issues visible.


πŸš€ Deployment

Deployment is straightforward:

βœ… Deploy the Google Chat bridge

βœ… Apply Prometheus alert rules

βœ… Update Alertmanager configuration

βœ… Restart Alertmanager

After deployment, test by sending a sample alert to Alertmanager and verify it reaches Google Chat.


πŸ“Š Result

The final solution delivers:

βœ… Real-time 4xx & 5xx error alerts

βœ… Pod crash notifications

βœ… HPA saturation alerts

βœ… Deployment health alerts

βœ… Resolved notifications

βœ… Minimal resource footprint

βœ… Fully self-hosted

βœ… No additional SaaS cost


#DevOps #Kubernetes #EKS #Prometheus #Alertmanager #Monitoring #SRE #CloudNative #PlatformEngineering #Observability #GoogleChat #k8s πŸš€