Prometheus Alertmanager receives alerts from the Prometheus server, deduplicates and groups them, and routes notifications to receivers such as Slack, email, PagerDuty, or OpsGenie. It also handles silencing and inhibition. Once Prometheus is scraping targets and evaluating rules, it can send alerts to Alertmanager when metrics cross thresholds—for example when a target is down. This guide walks through installing and configuring Alertmanager on Linux with systemd, wiring Prometheus to Alertmanager, creating an alert rule, and sending Slack notifications when a target is unavailable.
In this guide you’ll learn:
- How to install Prometheus Alertmanager on Linux and run it with systemd
- How to configure Prometheus to use Alertmanager and scrape its metrics
- How to create a Prometheus alert rule (e.g. InstanceDown when
up == 0) - How to configure Alertmanager with a Slack receiver so you get notifications in Slack
Prerequisites
You need a working Prometheus setup before proceeding. If you need to install or configure Prometheus first, see these guides:
- How to set up Prometheus Node Exporter in Kubernetes
- How to install and configure Prometheus on a Linux server
- How to monitor Linux servers using Prometheus Node Exporter
- How to run Prometheus with Docker and Docker Compose
Installing Alertmanager
Alertmanager is distributed as a tarball on the Prometheus downloads page. Download the latest Linux release. Example (replace the version if needed):
| |
Once the download is complete, extract it and move to the /opt/alertmanager directory.
| |
The directory contains the alertmanager binary and the alertmanager.yml configuration file. Since we’re running Alertmanager as the prometheus user (created during your Prometheus setup), give that user ownership of the directory:
| |
Creating a Data Directory
Alertmanager needs a data directory for its storage. Because the service runs as the prometheus system user, that user must own the directory (read, write, and execute).
You can create the data/ directory in the /opt/alertmanager/ directory as follows:
| |
Create a systemd unit for Alertmanager
Use systemd to manage Alertmanager so you can start, stop, restart, and enable it on boot. Create the unit file:
| |
And add the following content to the file
| |
Save and exit the file.
For the systemd changes to take effect, run the following command:
| |
Now, start the alertmanager service with the following command:
| |
Confirm that the service is running as expected by checking its status:
| |
Add the alertmanager service to the system startup so that it automatically starts on boot with the following command:
| |
Configuring Prometheus
Next, configure Prometheus to use Alertmanager and (optionally) scrape Alertmanager’s metrics. Both are done in this section.
Add a scrape job for Alertmanager in the scrape_configs section of prometheus.yml. If Alertmanager and Prometheus run on the same host, use 127.0.0.1:9093; otherwise use your Alertmanager host IP. You can find the host IP using this command:
| |
Example prometheus.yml with an Alertmanager scrape job:
| |
Also add Alertmanager as the alert receiver in the alerting.alertmanagers section of prometheus.yml:
| |
For the changes to take effect, restart the prometheus service as follows:
| |
Open http://<server_ip>:9090/targets in your browser; the alertmanager target should be UP, so Prometheus is successfully talking to Alertmanager.
Creating a Prometheus Alert Rule
On Prometheus, you can use the up expression to find the state of the targets added to Prometheus in the graph search section.
Targets in the UP state (reachable by Prometheus) have the value 1; targets that are DOWN (not running or unreachable) have the value 0.
If you stop one of the targets node_exporter (let’s say).
| |
The UP value of that target in prometheus should be 0. So, you can use the up == 0 expressions to list only the targets that are not running or inaccessible to Prometheus.
You can use this expression in a Prometheus alert rule so that when one or more targets are down, Prometheus sends the alert to Alertmanager.
To create a Prometheus Alert, create a new file rules.yml in the /opt/prometheus/ directory as follows:
| |
Now, type in the following lines in the rules.yml file.
| |
Here, the alert InstanceDown will be fired when targets are not running or inaccessible to Prometheus (that is up == 0) for a minute (1m).
Now, update the Prometheus configuration file /opt/prometheus/prometheus.yml as follows:
| |
Another important option of the prometheus.yml file is evaluation_interval. Prometheus will check whether any rules matched every evaluation_interval time. The default is 15s (15 seconds). So, the Alert rules in the rules.yml file will be checked every 15 seconds.
For the changes to take effect, restart the prometheus service:
| |
Now, navigate to the URL http://<server_ip>:9090/rules from your favorite web browser, and you should see the rule InstanceDown that you’ve just added.
Navigate to the URL http://<server_ip>:9090/alerts from your favorite web browser, and you should see the state of the alert InstanceDown.
Because you stopped node_exporter earlier, the alert is active and will be sent to Alertmanager once it has been firing for 1 minute.
After a minute, the InstanceDown alert should show as FIRING and Prometheus will have sent it to Alertmanager.
Configuring the Slack receiver in Alertmanager
Here we configure Slack as an Alertmanager receiver so you get messages in Slack when a Prometheus target is DOWN (or when any other configured alert fires).
If you want to receive notifications via Slack, you should be part of a Slack workspace. If you are currently not a part of any Slack workspace, or you want to test this out in separate workspace, you can quickly create one here.
To set up alerting in your Slack workspace, you’re going to need a Slack API URL. Go to Slack -> Administration -> Manage apps.
In the Manage apps directory, search for Incoming Webhooks and add it to your Slack workspace.
Next, specify in which channel you’d like to receive notifications from Alertmanager. (I’ve created #citizix-alerts channel.) After you confirm and add Incoming WebHooks integration, webhook URL (which is your Slack API URL) is displayed. Copy it.
Then edit /opt/alertmanager/alertmanager.yml. Use the webhook URL you copied as slack_api_url, and set channel to your Slack channel (e.g. #alerts):
| |
In the above configs, we have updated the alertmanager receiver to slack-notifications, the receiver we have created and added configs. It will use that from now on.
The repeat_interval in the route (default 1h) controls how often Alertmanager will re-send the same group of alerts. After sending a notification, it waits this long before sending again for that group. Increase it if you want fewer repeated notifications.
Now, restart the alertmanager service for the changes to take effect:
| |
You should get a message on Slack shortly (the InstanceDown alert for the stopped node_exporter).
Frequently Asked Questions (FAQ)
What is Prometheus Alertmanager?
Alertmanager is the component that receives alerts from Prometheus, deduplicates and groups them, and routes them to receivers such as Slack, email, or PagerDuty. It also handles silencing and inhibition so you can reduce noise and avoid duplicate notifications.
What port does Alertmanager use?
Alertmanager listens on port 9093 by default. Prometheus sends alerts to this port and can also scrape Alertmanager metrics from it for monitoring.
How do I send Prometheus alerts to Slack?
Configure a Slack Incoming Webhook in your workspace, then set slack_api_url in the global section of alertmanager.yml and add a receiver with slack_configs (including your channel). Point the route to that receiver so firing alerts are sent to Slack.
Why is my Prometheus alert not firing?
Ensure the alert rule expression (e.g. up == 0) is true for at least the for duration (e.g. 1m). Check http://<server>:9090/alerts for state (Pending vs Firing). Confirm alerting.alertmanagers in prometheus.yml points to your Alertmanager (e.g. 127.0.0.1:9093) and that rule_files includes your rules file.
Conclusion
You now have Prometheus Alertmanager installed on Linux, managed by systemd, with Prometheus configured to evaluate alert rules and send alerts to Alertmanager. By adding a Slack receiver, you get notifications in Slack when targets go down or other conditions fire. For richer alerting and enrichment (e.g. with Kubernetes), see how to set up Robusta for Kubernetes monitoring on EKS or production-ready Prometheus on Kubernetes.