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 a custom variable called slackAPI, this is a Slack channel specific data and we have to define it on Iciga Director before applying it on Notifications.
Go to Icinga Director --> Define Data Fields
Create new Data Field as follows:
- Slack WebHook URL
Slack Notification Templates
Create following templates with the given data.
- Slack Host Notification Template
- Include custom field we created earlier. Goto the Fields tab of the template and enter
slackAPI
as amandatory field.
- Slack Service Notification Template
- Goto the Fields tab of the template and enter
slackAPI
as mandatory fields based on previous guidelines.
Create Notifications to Slack
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.
- Slack-Host-Notification
- Slack-Service-Notification
- Finally, Deploy the changes you did.
Attachments (10)
- slackAPI.png (99.4 KB ) - added by 4 years ago.
- HostAlarm-Slack.png (124.0 KB ) - added by 4 years ago.
- SHT.png (100.3 KB ) - added by 4 years ago.
- Field_slackAPI.png (86.4 KB ) - added by 4 years ago.
- SHN.png (135.3 KB ) - added by 4 years ago.
- HAS-Args.png (65.5 KB ) - added by 4 years ago.
- ServiceAlarm-Slack.png (81.4 KB ) - added by 4 years ago.
- SAS-Args.png (88.9 KB ) - added by 4 years ago.
- SST.png (119.1 KB ) - added by 4 years ago.
- SSN.png (156.3 KB ) - added by 4 years ago.
Download all attachments as: .zip