Changes between Initial Version and Version 1 of NSM2021/Agenda/AlertsIcinga2Slack


Ignore:
Timestamp:
May 22, 2021, 7:53:24 PM (3 years ago)
Author:
admin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • NSM2021/Agenda/AlertsIcinga2Slack

    v1 v1  
     1= Icinga2 Notification to Slack through Director =
     2 
     3=== Prerequisite ===
     4
     5* SLACK API WEbHook URL created.
     6  If you haven't created these, please consult [wiki:NSM2021/Agenda/SlackGuide here]
     7* Notification Users are created in Icinga Director
     8
     9== Create new command on Icinga2 ==
     10
     11We have created custom bash codes to translate Icinga notifications to Slack. Download them into the scripts directory.
     12
     13{{{
     14#!sh
     15cd /etc/icinga2/scripts
     16
     17wget https://raw.githubusercontent.com/LEARN-LK/Tutorials/master/Scripts/ICINGA2/icinga2-slack-host.sh
     18
     19wget https://raw.githubusercontent.com/LEARN-LK/Tutorials/master/Scripts/ICINGA2/icinga2-slack-service.sh
     20
     21chmod +x icinga2-slack-host.sh
     22
     23chmod +x icinga2-slack-service.sh
     24}}}
     25
     26Then log into Icinga Director and create two commands as follows.
     27
     28* Host Alarm to Slack
     29
     30[[Image(HostAlarm-Slack.png, 600px, nolink)]]
     31
     32  Add following Arguments as well.
     33
     34[[Image(HAS-Args.png, 500px, nolink)]]
     35
     36* Service Alarm to Slack
     37
     38[[Image(ServiceAlarm-Slack.png, 600px, nolink)]]
     39
     40  Add following Arguments as well.
     41
     42[[Image(SAS-Args.png, 500px, nolink)]]
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53== Create Custom Variables ==
     54
     55Above 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.
     56
     57Go to Icinga Director --> `Data Field Categories`
     58
     59[[Image(DataCat1.png, 500px, nolink)]]
     60
     61Add a Data Category as below.
     62
     63[[Image(DataCat2.png, 500px, nolink)]]
     64
     65Then go to Icinga Director --> `Define Data Fields`
     66
     67Create two new Data Fields as follows:
     68
     69* Token Code
     70
     71[[Image(TokenCode.png, 500px, nolink)]]
     72
     73* Chat ID
     74
     75[[Image(ChatId.png, 500px, nolink)]]
     76
     77== Telegram Notification Templates ==
     78
     79Create following templates with the given data.
     80
     81* Telegram Host Notification Template
     82
     83[[Image(THT.png, 500px, nolink)]]
     84
     85* Include custom fields we created earlier. Goto the Fields tab of the template and enter chat_id and tockencode as mandatory fields
     86
     87[[Image(Field_chatId.png, 500px, nolink)]]
     88
     89[[Image(Field_tokencode.png, 500px, nolink)]]
     90
     91* Telegram Service Notification Template
     92
     93[[Image(TST.png, 500px, nolink)]]
     94
     95* Goto the Fields tab of the template and enter `chat_id` and `tockencode` as mandatory fields based on previous guidelines.
     96
     97== Create Notifications to Telegram ==
     98
     99In 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.
     100
     101* Telegram-Host-Notification
     102
     103[[Image(THS.png, 600px, nolink)]]
     104
     105* Telegram-Service-Notification
     106
     107[[Image(TSN.png, 600px, nolink)]]
     108
     109
     110* Finally, Deploy the changes you did.
     111