Alertmanager: Metric-Based Alerting in Prometheus
30%
Integrating Prometheus with Alertmanager
When Alertmanager sends alerts to an external service (Slack, MS Teams, email, etc.), it may send URLs that point to the Prometheus UI. To ensure that these URLs are accessible to the recipients, you need to add --web.external-url to the configuration file.
[...]
ExecStart=/usr/local/bin/prometheus [...] --web.external-url=http://:9090
[...]
To do this, start by exporting the IP address of the Prometheus server.
# Since we are accessing our Prometheus server from the outside,
# we can use the following command to get the public IP address of the server.
# If you are accessing the server using a domain name, you can use that domain name instead.
# If you are accessing the server using a private IP address, you can use that IP address instead.
export PROMETHEUS_IP=$(curl -s ifconfig.me)
echo "export PROMETHEUS_IP=$PROMETHEUS_IP" >> ~/.bashrc
source ~/.bashrc
You can now use the following command to add the --web.external-url flag to the Prometheus service file, overwriting the existing file.
cat << EOF > /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target
[Service]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.
