Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alerthandler

English version below

Alerthandler - модуль на языке python, который опрашивает KUMA по REST API v1 на предмет изменения информации об алертах и отправляет эту информацию в Alertmanager для дальнейшей их отправки выбранным получателям.

Требования

  • alertmanager 0.28
  • python 3.6+ (requests, pyyaml)

Установка

  1. Скачайте alerthandler-<version>.tar.gz на странице Releases
  2. Распакуйте архив: tar -xf alerthandler-<version>.tar.gz
  3. Перейдите в директорию: cd alerthandler/
  4. Задайте права на исполнение файлу install: chmod +x install.sh
  5. Запустите установку: sudo ./install.sh

В результате установки будет сделано следующее:

  • созданы директории /opt/alertmanager/ и /opt/alerthandler/
  • в директории помещены соответствующие файлы необходимые для работы программы
  • созданы службы alertmanager.service и alerthandler.service
  • созданы пользователи alerthandler и alertmanager

Настройка

  1. Правим файл конфигурации alertmanager под себя, можно использовать # чтобы закомментировать строки В текущей версии присутствуют примеры отправки в почту, телеграм и webhook. Остальные возможные варианты интеграции, а также более тонкая настройка существующих есть в документации на Alertmanager.
vi /opt/alertmanager/alertmanager.yml
  1. Переходим в директорию и запускаем вручную с дебаг-режимом для проверки отсутствия ошибок
cd /opt/alertmanager/
sudo -u alertmanager /opt/alertmanager/alertmanager --config.file /opt/alertmanager/alertmanager.yml --log.level=debug

Если выполнение не останавливается и в выводе присутствуют только INFO и DEBUG, значит все ок.

  1. Если все ок, можно запускать сервис
systemctl daemon-reload
systemctl enable alertmanager.service
systemctl start alertmanager.service
  1. Проверяем статус службы
systemctl status alertmanager.service
  1. Правим файл конфигурации alerthandler под себя, можно использовать # чтобы закомментировать строки
vi /opt/alerthandler/config.yml
  1. Переходим в директорию и запускаем вручную, чтобы проверить отсутствие ошибок
cd /opt/alerthandler/
sudo -u alerthandler python3 /opt/alerthandler/alerthandler.py

Если в выводе отсутствует какая-либо информация или traceback, значит все ок

  1. Если все ок можно запускать сервис:
systemctl enable alerthandler.service
systemctl start alerthandler.service
  1. Проверяем статус службы
systemctl status alerthandler.service

Примеры

Почтовое уведомление
Событие в KUMA с коннектором типа http и парсером JSON

English version

alerthandler

Alerthandler is a Python module that polls KUMA via REST API v1 for changes in alert information and forwards that information to Alertmanager for further delivery to selected recipients.

Requirements

  • alertmanager 0.28
  • python 3.6+ (requests, pyyaml)

Installation

  1. Download alerthandler-<version>.tar.gz from the Releases page
  2. Extract the archive: tar -xf alerthandler-<version>.tar.gz
  3. Navigate to the directory: cd alerthandler/
  4. Grant execute permission to the install script: chmod +x install.sh
  5. Run the installation: sudo ./install.sh

The installation will perform the following:

  • create directories /opt/alertmanager/ and /opt/alerthandler/
  • place the necessary program files into the respective directories
  • create alertmanager.service and alerthandler.service systemd services
  • create alerthandler and alertmanager system users

Configuration

  1. Edit the alertmanager configuration file to suit your needs. You can use # to comment out lines. The current version includes examples for email, Telegram, and webhook delivery. For other integration options and more advanced configuration, refer to the Alertmanager documentation.
vi /opt/alertmanager/alertmanager.yml
  1. Navigate to the directory and run manually in debug mode to check for errors
cd /opt/alertmanager/
sudo -u alertmanager /opt/alertmanager/alertmanager --config.file /opt/alertmanager/alertmanager.yml --log.level=debug

If the process does not stop and the output contains only INFO and DEBUG entries, everything is working correctly.

  1. If everything is ok, start the service
systemctl daemon-reload
systemctl enable alertmanager.service
systemctl start alertmanager.service
  1. Check the service status
systemctl status alertmanager.service
  1. Edit the alerthandler configuration file to suit your needs. You can use # to comment out lines.
vi /opt/alerthandler/config.yml
  1. Navigate to the directory and run manually to check for errors
cd /opt/alerthandler/
sudo -u alerthandler python3 /opt/alerthandler/alerthandler.py

If there is no output or traceback, everything is working correctly.

  1. If everything is ok, start the service:
systemctl enable alerthandler.service
systemctl start alerthandler.service
  1. Check the service status
systemctl status alerthandler.service

Examples

Email notification
KUMA event with an HTTP connector and JSON parser

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages