Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Alerting with Prometheus Alertmanager
📖 Scenario: You are managing a Kubernetes cluster and want to monitor the health of your applications. You will set up Prometheus Alertmanager to send alerts when your application metrics cross certain thresholds.
🎯 Goal: Build a simple Prometheus alerting rule and configure Alertmanager to send notifications when the alert fires.
📋 What You'll Learn
Create a Prometheus alerting rule for high CPU usage
Configure Alertmanager with a basic alert receiver
Connect Prometheus to Alertmanager
Test the alert and display the alert firing message
💡 Why This Matters
🌍 Real World
Monitoring applications in Kubernetes clusters is critical to detect issues early. Prometheus and Alertmanager help automate alerting to notify teams.
💼 Career
DevOps engineers and SREs use Prometheus and Alertmanager daily to maintain system reliability and respond quickly to problems.
Progress0 / 4 steps
1
Create Prometheus Alerting Rule
Create a file called cpu_alert_rule.yaml with a Prometheus alerting rule named HighCpuUsage that triggers when rate(container_cpu_usage_seconds_total[5m]) > 0.5 for 5 minutes.
Kubernetes
Hint
Use the alert, expr, and for fields inside a rules list.
2
Configure Alertmanager Receiver
Create a file called alertmanager.yaml with a receiver named team-email that sends alerts to the email address team@example.com.
Kubernetes
Hint
Define receivers with a name and email_configs including the to email address.
3
Connect Prometheus to Alertmanager
Add the Alertmanager configuration to Prometheus by creating a prometheus.yaml file that includes the Alertmanager URL http://alertmanager:9093 under the alerting section.
Kubernetes
Hint
Under alerting, add alertmanagers with static_configs and targets listing the Alertmanager URL.
4
Test Alert and Display Output
Print the message Alert fired: HighCpuUsage to simulate the alert firing.
Kubernetes
Hint
Use a print statement to show the alert firing message exactly as given.
Practice
(1/5)
1. What is the main role of Prometheus Alertmanager in Kubernetes monitoring?
easy
A. To collect metrics from Kubernetes nodes
B. To send notifications when Prometheus detects alerts
C. To store logs from containers
D. To deploy applications automatically
Solution
Step 1: Understand Prometheus and Alertmanager roles
Prometheus collects metrics and detects alerts based on rules.
Step 2: Identify Alertmanager's function
Alertmanager receives alerts from Prometheus and sends notifications to users or systems.
Final Answer:
To send notifications when Prometheus detects alerts -> Option B
Quick Check:
Alertmanager = Notification sender [OK]
Hint: Alertmanager handles alert notifications, not metric collection [OK]
Common Mistakes:
Confusing Alertmanager with Prometheus server
Thinking Alertmanager collects metrics
Assuming Alertmanager deploys apps
2. Which of the following is the correct YAML snippet to define an email receiver named 'team-email' in Alertmanager?
easy
A. receivers:
- name: team-email
email_configs:
- to: 'team@example.com'
B. receivers:
- team-email:
email: 'team@example.com'
C. receiver:
name: team-email
email: 'team@example.com'
D. receivers:
- name: team-email
slack_configs:
- channel: '#alerts'
Solution
Step 1: Review Alertmanager receiver syntax
Receivers are defined under 'receivers' list with 'name' and config type like 'email_configs'.
Step 2: Match correct YAML structure
receivers:
- name: team-email
email_configs:
- to: 'team@example.com' correctly uses 'receivers', 'name', and 'email_configs' with 'to' field.
Final Answer:
Correct YAML with 'receivers', 'name', and 'email_configs' -> Option A
Quick Check:
Receiver YAML uses 'name' and 'email_configs' [OK]
Hint: Receiver configs use 'name' and specific config like 'email_configs' [OK]
Common Mistakes:
Using 'receiver' instead of 'receivers'
Incorrect nesting of email fields
Confusing slack_configs with email_configs
3. Given this Alertmanager config snippet, what will happen when multiple alerts fire simultaneously?
A. Alertmanager does not support email notifications
B. Incorrect 'group_by' label causes no alerts
C. Receiver name does not match route receiver
D. Missing SMTP server configuration in Alertmanager
Solution
Step 1: Check email notification requirements
Email notifications require SMTP server settings in Alertmanager config, not shown here.
Step 2: Verify receiver and route match
Receiver name 'team-email' matches route receiver, so routing is correct.
Final Answer:
Missing SMTP server configuration in Alertmanager -> Option D
Quick Check:
Email needs SMTP setup to send alerts [OK]
Hint: Email alerts need SMTP server configured in Alertmanager [OK]
Common Mistakes:
Assuming 'group_by' label stops alerts
Thinking receiver name mismatch causes no alerts here
Believing Alertmanager can't send emails
5. You want to avoid alert spam by grouping alerts by both 'alertname' and 'severity', and send notifications to Slack channel '#alerts'. Which Alertmanager route and receiver config is correct?