wiki:NSM2021/Agenda/AlertsIcinga2Slack

Version 1 (modified by admin, 3 years ago) ( diff )

--

Icinga2 Notification to Slack through Director

Prerequisite

  • SLACK API WEbHook URL created. If you haven't created these, please consult here
  • Notification Users are created in Icinga Director

Create new command on Icinga2

We have created custom bash codes to translate Icinga notifications to Slack. Download them into the scripts directory.

cd /etc/icinga2/scripts

wget https://raw.githubusercontent.com/LEARN-LK/Tutorials/master/Scripts/ICINGA2/icinga2-slack-host.sh

wget https://raw.githubusercontent.com/LEARN-LK/Tutorials/master/Scripts/ICINGA2/icinga2-slack-service.sh

chmod +x icinga2-slack-host.sh

chmod +x icinga2-slack-service.sh

Then log into Icinga Director and create two commands as follows.

  • Host Alarm to Slack

Add following Arguments as well.

  • Service Alarm to Slack

Add following Arguments as well.

Create Custom Variables

Above scripts uses two custom variables called tokencode and chat_id, these are Telegram User specific data and we have to define them on Iciga Director before applying it on Notifications.

Go to Icinga Director --> Data Field Categories

No image "DataCat1.png" attached to NSM2021/Agenda/AlertsIcinga2Slack

Add a Data Category as below.

No image "DataCat2.png" attached to NSM2021/Agenda/AlertsIcinga2Slack

Then go to Icinga Director --> Define Data Fields

Create two new Data Fields as follows:

  • Token Code

No image "TokenCode.png" attached to NSM2021/Agenda/AlertsIcinga2Slack

  • Chat ID

No image "ChatId.png" attached to NSM2021/Agenda/AlertsIcinga2Slack

Telegram Notification Templates

Create following templates with the given data.

  • Telegram Host Notification Template

No image "THT.png" attached to NSM2021/Agenda/AlertsIcinga2Slack

  • Include custom fields we created earlier. Goto the Fields tab of the template and enter chat_id and tockencode as mandatory fields

No image "Field_chatId.png" attached to NSM2021/Agenda/AlertsIcinga2Slack

No image "Field_tokencode.png" attached to NSM2021/Agenda/AlertsIcinga2Slack

  • Telegram Service Notification Template

No image "TST.png" attached to NSM2021/Agenda/AlertsIcinga2Slack

  • Goto the Fields tab of the template and enter chat_id and tockencode as mandatory fields based on previous guidelines.

Create Notifications to Telegram

In this setup, we shall create two notifications setups for Hosts and Services respectively. When assigning notifications we should select a user rather than a user group to avoid multiple duplicates of notifications.

  • Telegram-Host-Notification

No image "THS.png" attached to NSM2021/Agenda/AlertsIcinga2Slack

  • Telegram-Service-Notification

No image "TSN.png" attached to NSM2021/Agenda/AlertsIcinga2Slack

  • Finally, Deploy the changes you did.

Attachments (10)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.