Prometheus alertmanager: Difference between revisions

From wikinotes
Line 52: Line 52:
   smtp_smarthost: 'localhost:25'
   smtp_smarthost: 'localhost:25'
   smtp_from: 'alertmanager@example.org'
   smtp_from: 'alertmanager@example.org'
  smtp_auth_username: 'alertmanager'
  smtp_auth_password: 'password'


route:
route:

Revision as of 00:45, 19 February 2022

Alertmanager is the official service prometheus communicates with to issue alerts.

Documentation

repo https://github.com/prometheus/alertmanager
official docs https://prometheus.io/docs/alerting/latest/configuration/
sample config https://github.com/prometheus/alertmanager#example

Locations

9093 default port that receives alerts
${PREFIX}/etc/alertmanager/alertmanager.yml config

Install

pkg install alertmanager  # FreeBSD
pacman -S alertmanager    # Archlinux

You'll also need to enable/start the service.

Configuration

AlertManager

AlertManager can issue notifications using various methods.
See docs for all options

SMTP

First, setup a send-only postfix install on the localhost.

# /usr/local/etc/alertmanager/alertmanager.yml

global:
  smtp_smarthost: 'localhost:25'
  smtp_from: 'alertmanager@example.org'
  smtp_auth_username: 'alertmanager'
  smtp_auth_password: 'password'

route:
  receiver: smtp-local

receivers:
  - name: 'smtp-local'
    email_configs:
    - to: 'to@domain.com'
      from: 'foo@domain.com'
      require_tls: false
      smarthost: localhost:25
      send_resolved: true

HTTP

Prometheus

# /usr/local/etc/prometheus.yml

alerting:
  alertmanagers:
    - static_configs:
      - targets: ['localhost:9093']

Usage

amtool check-config alertmanager.yml  # validate an alertmanager config