Alertmanager: Metric-Based Alerting in Prometheus
Installing Alertmanager
Alertmanager is distributed as a standalone application that can be installed on the same host as the Prometheus server or on a separate host. To install it, you can download the binary from the GitHub repository and run it directly on your host.
Example (we are not going to use this approach):
# Create the directory structure
mkdir -p $GOPATH/src/github.com/prometheus
cd $GOPATH/src/github.com/prometheus
# Clone Alertmanager repository
git clone https://github.com/prometheus/alertmanager.git
cd alertmanager
# Checkout the latest release
git checkout v0.28.1
# Build Alertmanager
make build
# Run Alertmanager
./alertmanager --config.file=
Alternatively, you can use the Docker image available on Docker Hub. This approach is recommended for testing and development environments. If you want to use Docker in production, consider deploying the Alertmanager container using a container orchestration tool such as Kubernetes.
Example (we are not going to use this approach):
# Example with Docker
docker run -d \
--name alertmanager \
-p 9093:9093 \
quay.io/prometheus/alertmanager
# Example with Helm (Kubernetes)
helm repo add \
prometheus-community \
https://prometheus-community.github.io/helm-charts
helm repo update
helm install \
alertmanager \
prometheus-community/prometheus-alertmanager \
--namespace monitoring \
--create-namespace \
--set replicaCount=2 \
--set hostDomain=mydomain.com
Another option is to create a systemd service file to manage Alertmanager as a service. This is what we are going to do in this guide. We are always using the same server (monitoring).
ℹ️ Alertmanager can be installed on the same host as the Prometheus server or on a separate host.
Start by creating a new user to run the Alertmanager service.
sudo useradd \
--no-create-home \
--shell /bin/false alertmanager
Download the latest Alertmanager release from the Prometheus GitHub repository.
url="https://github.com/prometheus/alertmanager/releases/download/v0.28.1/alertmanager-0.28.1.linux-amd64.tar.gz"Observability with Prometheus and Grafana
A Complete Hands-On Guide to Operational Clarity in Cloud-Native SystemsEnroll now to unlock all content and receive all future updates for free.
