1. Home
  2. Integrations
  3. Creating ServiceNow Web Hook

Creating ServiceNow Web Hook

The following instructions are for generating Exoprise Alarms in ServiceNow utilizing Webhooks. The JSON provided will raise a Critical Incident and include the Failed sensors name, time of failure, site information, number of occurrences that triggered the sensor, and a link to the sensor to review, tune up or tune down. It can be further customized to include additional information as well.

 ServiceNow Account

    • First you will need to create an account in ServiceNow with the permissions to create an incident.
    • When doing our testing we did not have to assign any permissions to the account for it to have the ability to create Incidents. Different instances of ServiceNow may be different though.

Creating the Webhook in Exoprise

    • Once logged in to Exoprise, navigate to Alarms and then Settings.
    • From settings, select the Web Hooks tab then click Add.
    • Fill in the name you would like to provide the Web Hook.
    • Copy your ServiceNow URL up to .com and add the following ‘/api/now/v1/table/incident’ it should look like
      https://yourinstance.service-now.com/api/now/v1/table/incident
    • Copy and paste the URL into the Target URL field.
    • Set the Requested Method to Post
    • Set the Content Type to application/json
    • Leave the Custom Headers blank
    • Check the Enable Basic Authorization checkbox
    • Input the Username and Secret (users password) you created.
    • Check the Enable Ring Event.
    • The following JSON will create the Incidents in ServiceNow like the initial screenshot. Make sure to replace the “YourWebHookUser” value of “caller_id” with your user.

{
“short_description”: “Alarm:$alarm.name$ on $alarm.site.display_name$ with AlertID $alarm.alert_id$”,
“impact”: “1”,
“urgency”: “1”,
“caller_id”: “ServiceNowExoprise”

}


    • Click Save.

 

Assigning Web Hook to Alarms

    • From the Secure.Exoprise.com page, select Alarms and then Alarm Dashboard on the left menu.
    • Select the Alarm you want to assign the Web Hook to by clicking it’s name in the Alarm column.
    • In the Alarm itself, select Edit in the top left.
    • In the Web Hook drop down, select the Web Hook you created and click ‘Update Alarm’ in the bottom left.
    • Once complete, that Alarm will start generating incidents in ServiceNow

Automatically Closing Incidents in ServiceNow

Creating the Business Rule

    • In service now, create a new Business Rule
    • Provide it with a name
    • Select the Incident Table
    • Specify the Application
    • Check the Active Box and Advanced Box
    • In the “When to run” section at the bottom check the “Insert” checkbox and select after from the When drop down menu. Specify the Order in which you want the Business Rule to run against the Incidents table.
    • Click on the Advanced Tab
    • Input the following for the Condition

Condition

current.short_description.indexOf(‘ExopriseResolved:’) != -1


 

  • Copy and paste the following script into the script section

Script for Condition

(function executeRule(current, previous /*null when async*/ ) {

 

        // Setting Variables

        var grExoprise = new GlideRecord(‘incident’);

        var str = current.short_description;

        var TicketString = str.replace(“ExopriseResolved:”, “Alarm:”);

        var OriginalTicket = (TicketString);

        // Identifies Original Ticket Opened by Exoprise

        grExoprise.addQuery(‘short_description’, OriginalTicket);

        grExoprise.query();

        // Closes tickets and any duplicates

        grExoprise.state = 7;

        grExoprise.updateMultiple();

    }

)(current, previous);


 

    • Click Submit to create the Business Rule
    • Once complete, you will need to enable the Resolve Event option in the Webhook.
    • In Exoprise, go to Alarms and then Settings from the left menu and click into Web Hooks and select your ServiceNow Web Hook.
    • Check the “Enable Resolve Event” checkbox and copy and paste the following in the bottom “Message Body” field.

Web Hook Resolution

{
“short_description”: “ExopriseResolved:$alarm.name$ on $alarm.site.display_name$ with AlertID $alarm.alert_id$”,
“impact”: “1”,
“urgency”: “1”,
“caller_id”: “ServiceNowExoprise”,
“state”: “7”

}


    • Click Save

Please Note –

The provided JSON will Create a ticket with a priority of Critical (1) and the Alert Subject generated by Exoprise. The JSON can be customized further to include additional information. However, if you plan on using the auto close function, the Short Description for the Ring Event needs to start with Alarm: and the Resolve Events Short Description needs to start with ExopriseResolved to use the Business Rule in this documentation.

Related Articles