Source: Dev.to | Jan 18, 2026 (UTC)
TL;DR: Traditional alerting methods often lead to alert fatigue or high costs. This guide details how to integrate Prometheus, Alertmanager, and Discord via webhooks to establish a robust, real-time, and cost-effective system for sending custom alert notifications directly to your team’s communication channel.
- Discord webhooks provide a unique URL that allows services like Alertmanager to send messages to specific channels without requiring a bot or user account, acting as a simple yet powerful integration point.
- Prometheus alerting rules define conditions using PromQL expressions, a
forduration to prevent flapping, andlabelsandannotationsto provide context for Alertmanager’s processing and routing. - Alertmanager’s configuration (
alertmanager.yml) usesroutesto define alert grouping logic (group\_by,group\_wait,repeat\_interval) andreceiverswithwebhook\_configsto specify output destinations like Discord, includingsend\_resolved: truefor resolution notifications.
How to Send Custom Prometheus Alerts to Discord via Webhooks
As a Senior DevOps Engineer at TechResolve, I’ve seen firsthand the challenges of maintaining effective communication during critical system events. In the fast-paced world of site reliability, getting timely notifications about infrastructure and application issues is paramount. Relying solely on email, SMS, or even proprietary SaaS solutions can often lead to alert fatigue, missed incidents, or unnecessary expenses.
Imagine a scenario where your production database CPU spikes, or a critical microservice starts returning 500 errors. How quickly would your team know? Would they have to manually check dashboards, or would an alert immediately notify the right people in their preferred communication channel?
This is where the power of Prometheus for monitoring, Alertmanager for alert processing, and Discord for team communication comes into play. By integrating these tools, you can transform reactive troubleshooting into proactive incident response, without breaking the bank on expensive third-party tools. This tutorial will guide you through setting up a robust, real-time alerting system that pushes custom Prometheus alerts directly to your team’s Discord server using webhooks.
Before we dive into the configuration, ensure you have the following in place:
- A Running Prometheus Instance: Your Prometheus server should be up and actively scraping metrics from your targets.
- A Running Prometheus Alertmanager Instance: Alertmanager is crucial for processing, grouping, and routing alerts generated by Prometheus.
- Access to a Discord Server: You’ll need permissions to create and manage webhooks within a Discord server and channel.
- Basic Understanding of YAML: Prometheus and Alertmanager configurations are written in YAML, so familiarity with its syntax is helpful.
- A Linux Environment: Or any environment where you can access and modify your Prometheus and Alertmanager configuration files.
Let’s walk through the process of setting up this integration, from configuring Discord to defining your Alertmanager routes.
Step 1: Create a Discord Webhook
A Discord webhook acts as a unique URL that allows services like Alertmanager to send messages to a specific channel without needing a bot or user account. It’s a simple, yet powerful, integration point.
- Open your Discord client or browser.
- Navigate to the server where you want to receive alerts.
- Right-click on the desired text channel (e.g.,
#devops-alerts) and select Edit Channel. - In the channel settings, go to Integrations.
- Click on Create Webhook (or View Webhooks if you have existing ones, then New Webhook).
- Give your webhook a descriptive name (e.g.,
Prometheus Alerts) and optionally an image. - Ensure the correct channel is selected.
- Click Copy Webhook URL. Save this URL; you’ll need it for Alertmanager configuration.
- Click Save Changes.
Security Note: Treat your webhook URL like a sensitive credential. Anyone with the URL can post messages to your Discord channel. Do not share it publicly or commit it directly into public repositories.
Step 2: Define Prometheus Alerting Rules
Prometheus evaluates expressions based on your scraped metrics to determine if an alert condition is met. These rules are defined in a YAML file, typically named alert.rules.yml or similar, and then included in your main prometheus.yml configuration.
Let’s create a simple rule to trigger an alert if a server’s CPU usage exceeds 90% for at least 5 minutes.
Create a file, for example, /etc/prometheus/rules/cpu_alerts.yml, with the following content:
groups: - name: server_cpu_alerts rules: - alert: HighCPUUsage expr: 100 - (avg by (instance) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > 90 for: 5m labels: severity: critical team: infrastructure annotations: summary: "High CPU usage detected on {{ $labels.instance }}" description: "The CPU usage on instance {{ $labels.instance }} has been above 90% for more than 5 minutes. Current value: {{ $value | humanize }}%."
Enter fullscreen mode
Exit fullscreen mode



Залишити відповідь