Configure Alert Manager to Send Alerts from Prometheus

Video Lecture

Configure Alert Manager to Send Alerts from Prometheus Configure Alert Manager to Send Alerts from Prometheus Configure Alert Manager to Send Alerts from Prometheus

Description

We now configure the Prometheus and Alert Manager processes to communicate with each other, and to send alerts when the alerting rules fire.

Edit Alert Manager Configuration

Open the Alert Manager config file, and replace the config with this below.

sudo nano /usr/local/bin/alertmanager/alertmanager.yml

new

route:
  group_by: ['alertname']
  receiver: smtp-local
receivers:
  - name: 'smtp-local'
    email_configs:
    - to: 'your email address'
      from: 'your email from address'
      require_tls: false
      smarthost: localhost:25
      send_resolved: true

Check your configuration with the supplied amtool

/usr/local/bin/alertmanager/amtool check-config /usr/local/bin/alertmanager/alertmanager.yml

If all is ok, restart the Alert Manager service.

sudo service alertmanager restart
sudo service alertmanager status

Edit Prometheus Configuration

Open the prometheus.yml configuration file and add the text below to the alerting section

sudo nano /usr/local/bin/prometheus/prometheus.yml

Add - localhost:9093 to your Alertmanager configuration section

alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # alertmanager:9093
      - localhost:9093

Check the prometheus configuration with the supplied promtool.

/usr/local/bin/prometheus/promtool check config /usr/local/bin/prometheus/prometheus.yml
sudo service prometheus restart
sudo service prometheus status

Test Settings

Check the Prometheus UI

[Status]-->[Runtime and Build Information]

Copy the url in the Alertmanagers section

http://localhost:9093/api/v1/alerts

Test it using curl


The response should be success.

Now Check the Alert Manager UI

and a new scrape target to the prometheus.yml configuration

  - job_name: 'alert-manager'
    static_configs:
    - targets: ['localhost:9093']

And restart

sudo service prometheus restart
sudo service prometheus status