In today’s digital landscape, effective monitoring and alerting are critical for ensuring system performance and reliability. Prometheus, paired with Alertmanager, provides a robust framework for monitoring metrics and sending alerts. In this blog, we’ll walk through setting up Prometheus to monitor RAM usage and configuring Alertmanager to send a Discord alert when the RAM usage reaches 60%.
Prerequisites
Before starting, ensure the following are installed and configured:
- Prometheus: For monitoring system metrics.
- Node Exporter: To expose system metrics to Prometheus.
- Alertmanager: To manage and send alerts.
- Discord Webhook URL: For sending alerts to a specific Discord channel.
- Prometheus Alertmanager and Node Exporter are already installed and configured.
Step 1: Monitor RAM Usage with Prometheus
Prometheus requires Node Exporter to collect system-level metrics, including RAM usage.
Refer this blog if Node Exporter is not install : Link
Verify Node Exporter is running by visiting: http://<your_server_ip>:9100/metrics
.
Step 2: Set Up Alertmanager for Discord Alerts
Alertmanager handles alerts triggered by Prometheus and can send them to various endpoints.
Configure Alertmanager for Discord
Create a Discord Webhook:
- Open your Discord channel settings.
- Navigate to Integrations > Webhooks > New Webhook.
- Copy the generated Webhook URL.
Edit Alertmanager Configuration: Update alertmanager.yml
:
cd /etc/alertmanager
sudo nano /etc/alertmanager/alertmanager.yml
Edit the alertmanager yml file
global:
resolve_timeout: 5m
receivers:
- name: "discord-alerts"
webhook_configs:
- url: "<your_discord_webhook_url>"
route:
group_by: ['alertname']
receiver: "discord-alerts"
group_wait: 10s
group_interval: 10s
repeat_interval: 1h