The above works fine.
Now what I would like to set up is an event handler that calls a webhook once a warning is triggered for only this specific host.
How can this be done, please? I tried following the documentation but couldn’t figure it out.
on our old Icinga 1.x (just for use of internal monitoring), we have a notification command that calls a webhook into Slack for slack notifications. I scrape and store an email to user ID in a redis db – the notification send the email to the command, looks up the user ID in redis, and sends a slack message.
Not a webhook, but we also use a custom notification to send alerts into a rabbitmq queue to be processed to create or update tickets as well.
Notification commands don’t have to “notify” at all per se – it can call a script that runs reboot now for all it cares.
I could not understand how notification commands can be called and triggered when a warning happens.
I opted to work with event handlers but can’t seem to make it work either.
I created a file at /etc/icinga2/zones.d/a_zone/commands.conf
Let’s take the webhook out of the equation for a moment and say that you want to send email alerts when a warning happens for a given host and/or service:
you would define the email command (Icinga includes this by default iirc)
you would set up a notification template. In the template, you would specify that you only care about “Warning” state transitions
you would create a notification apply rule, import the template, and apply the notification to the service(s)/host(s) that you care about
I’m not sure about event commands here, for all I know what you have above is right, what do the logs say when the warning is triggered? You can probably tail -f /var/log/icinga2/icinga2.log | grep -i restart_service and find out; or just grep -i restart_service /var/log/icinga2/icinga2.log to see what has happened before.