Skip to main content

Lab 11.4 - Alerting and Notifications

Lab Objectives​

By the end of this lab, you will be able to:

  • Understand Alertmanager.
  • Configure alerting rules in Prometheus.
  • Configure routes and receivers in Alertmanager.
  • Test alerts.

Estimated Duration​

45-60 minutes

Prerequisites​

  • Prometheus installed (Lab 11.1).
  • Knowledge of Prometheus.

Part 1: Configuring Alerting Rules​

Step 1.1: Create an Alerting Rule​

Create alert-rules.yaml:

groups:
- name: kubernetes-alerts
rules:
- alert: HighCPUUsage
expr: rate(container_cpu_usage_seconds_total[5m]) > 0.8
for: 5m
labels:
severity: warning
annotations:
summary: "High CPU usage detected"
description: "CPU usage is above 80%"

Part 2: Configuring Alertmanager​

Step 2.1: Configure Alertmanager​

Create alertmanager-config.yaml:

global:
resolve_timeout: 5m

route:
group_by: ['alertname']
receiver: 'default-receiver'

receivers:
- name: 'default-receiver'
webhook_configs:
- url: 'http://webhook-receiver:5001/alerts'

Part 3: Testing Alerts​

Step 3.1: Verify Alerts​

Access Prometheus and verify the alerts:

http://localhost:9090/alerts

Lab Summary​

In this lab, you configured alerting with Prometheus and Alertmanager. You created alerting rules and configured notifications.


Next Steps​

This module on Monitoring is now complete. You can move on to Module 12 on Production Deployment.

Module 12: Production Deployment


Lab created on: December 2024