How to edit the slack notification alerts

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
IT-OPS-SYS
Posts: 184
Joined: Sun Jan 07, 2018 12:56 pm

How to edit the slack notification alerts

Post 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.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: How to edit the slack notification alerts

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
IT-OPS-SYS
Posts: 184
Joined: Sun Jan 07, 2018 12:56 pm

Re: How to edit the slack notification alerts

Post 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 .
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: How to edit the slack notification alerts

Post by cdienger »

It's an available macro(see https://assets.nagios.com/downloads/nag ... olist.html) and can be added to the commands.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
IT-OPS-SYS
Posts: 184
Joined: Sun Jan 07, 2018 12:56 pm

Re: How to edit the slack notification alerts

Post 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
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: How to edit the slack notification alerts

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
IT-OPS-SYS
Posts: 184
Joined: Sun Jan 07, 2018 12:56 pm

Re: How to edit the slack notification alerts

Post 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 .
You do not have the required permissions to view the files attached to this post.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: How to edit the slack notification alerts

Post 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$"
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
IT-OPS-SYS
Posts: 184
Joined: Sun Jan 07, 2018 12:56 pm

Re: How to edit the slack notification alerts

Post 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$”
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: How to edit the slack notification alerts

Post by cdienger »

Thanks for the update and providing a work around.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked