Page 1 of 1

How to edit the slack notification alerts

Posted: Tue Nov 05, 2019 8:36 am
by IT-OPS-SYS
we have integrated the nagios with the slack and as of now we are getting the alerts in slack like below:
============================
Host ‘hostname’ is DOWN:
CRITICAL - x.x.x.x: rta nan, lost 100%
================================
we would like to edit the alerts so that we can have the hostname followed by the hostgroupname like below:
=============================
Host ‘hostname’ - 'hostgroupname' is DOWN:
CRITICAL - x.x.x.x: rta nan, lost 100%
======================================
Commands used for notify-host-by-slack :

notify-host-by-slack $USER1$/slack_nagios.pl -field slack_channel="$CONTACTPAGER$" -field -field HOSTALIAS="$HOSTNAME$" -field NOTES="$HOSTNOTES$" -field HOSTSTATE="$HOSTSTATE$" -field HOSTOUTPUT="$HOSTOUTPUT$" -field NOTIFICATIONTYPE="$NOTIFICATIONTYPE$"

notify-service-by-slack :

notify-service-by-slack $USER1$/slack_nagios.pl -field slack_channel="$CONTACTPAGER$" -field HOSTALIAS="$HOSTNAME$" -field SERVICEDESC="$SERVICEDESC$" -field SERVICESTATE="$SERVICESTATE$" -field SERVICEOUTPUT="$SERVICEOUTPUT$" -field NOTIFICATIONTYPE="$NOTIFICATIONTYPE$"

===============================================================
contact used for slack integration has the settings proper.

Re: How to edit the slack notification alerts

Posted: Tue Nov 05, 2019 3:56 pm
by cdienger
The notification format is controlled by the Slack app and not something that XI can change. You'll need to contact the App developers to see if it can be modified. They provide [email protected] on the app page - https://slack.com/apps/A0F81R747-nagios?next_id=0

Re: How to edit the slack notification alerts

Posted: Mon Nov 11, 2019 1:27 pm
by IT-OPS-SYS
would it be possible to add the field "HOSTGROUP" to the notify-host-by-slack or notify-service-by-slack command .

Re: How to edit the slack notification alerts

Posted: Mon Nov 11, 2019 2:04 pm
by cdienger
It's an available macro(see https://assets.nagios.com/downloads/nag ... olist.html) and can be added to the commands.

Re: How to edit the slack notification alerts

Posted: Thu Nov 14, 2019 9:50 am
by IT-OPS-SYS
I added the Feld but do not see any alerts format changed. do we need to restart any service for that or any other contact we need to set up for this.

Kindly help

Re: How to edit the slack notification alerts

Posted: Thu Nov 14, 2019 2:30 pm
by cdienger
The notification format is controlled by the Slack app and not something that XI can change. You'll need to contact the App developers to see if it can be modified. They provide [email protected] on the app page - https://slack.com/apps/A0F81R747-nagios?next_id=0

Re: How to edit the slack notification alerts

Posted: Fri Nov 15, 2019 6:24 am
by IT-OPS-SYS
can u at-least give the field name for the below command line as what field can i use for the "hostgroup name".

Command Line:
$USER1$/slack_nagios.pl -field slack_channel="#hosts" -field HOSTALIAS="$HOSTNAME$" -field HOSTSTATE="$HOSTSTATE$" -field HOSTOUTPUT="$HOSTOUTPUT$" -field NOTIFICATIONTYPE="$NOTIFICATIONTYPE$"

see the attached screenshot and see how can i use the filed hostgroup name in the command .

Re: How to edit the slack notification alerts

Posted: Fri Nov 15, 2019 1:28 pm
by cdienger
The command could be edited to look like:

Code: Select all

$USER1$/slack_nagios.pl -field slack_channel="#hosts" -field HOSTALIAS="$HOSTNAME$" -field HOSTSTATE="$HOSTSTATE$" -field HOSTOUTPUT="$HOSTOUTPUT$" -field NOTIFICATIONTYPE="$NOTIFICATIONTYPE$" -field HOSTGROUPNAME="$HOSTGROUPNAME$"

Re: How to edit the slack notification alerts

Posted: Tue Dec 10, 2019 1:44 pm
by IT-OPS-SYS
i fixed it by editing the below:

edit the commands and change the following: -field HOSTALIAS=“$HOSTNAME$”
to
-field HOSTALIAS=“$HOSTNAME$ - $HOSTGROUPNAME$”

Re: How to edit the slack notification alerts

Posted: Tue Dec 10, 2019 4:00 pm
by cdienger
Thanks for the update and providing a work around.