ServiceNow Integration


This document is a walk through on how to configure Vyopta monitors to generate tickets in ServiceNow using webhook notifications. This document also covers the changes needed within Service Now to enable the integration.



  • Created a Scripted REST API in Service Now 
  • Create a custom Table in Service Now to track alerts coming in 


 Configuring Webhooks in Vyopta

This section will walk through setting up a webhook for a monitor in Vyopta. 

  1. Go to Vyopta CPM Monitoring 
  2. Click on Rules located under Monitors on the Left Menu 
  3. Click Add Monitor if you’re configuring a new monitor or click the name of an existing monitor
  4. Once the monitor is configured, go to the “Notify” section and click “Add Webhook” 
  5. Provide a name for the monitor and ensure the all the days are selected and the Active Schedule is set from 00:00 to 23:59
  6. In the “Data” field add the following – We will use the example below: 
Content-Type: application/json
"id": "[(${alertId})]",
"name": "[(${name})]",
"description": "[(${category})] [(${metric})] [(${description})] [(${operation})] [(${threshold})] for [(${alertDurationMinutes})] minutes",
"group": "[(${group})]",
"status": "[(${status})]",
"category": "[(${category})]",
"metric": "[(${metric})]",
"alertFiredTime": "[(${alertFiredTimeMs})]"

**Note: Additional fields can be added by clicking on the following icon: 


    7. Save the Monitor


Service Now Setup

To configure ServiceNow to accept webhooks from Vyopta and track the status, both a custom table is required and a Scripted Rest API.  


Custom Table Configuration 

  1. Head to the Tables located under the System Definition Menu 
  2. Click on “New” 
  3. Fill in the Label Name. We recommend using vyopta_alerts 
  4. Under the Columns Tab, click double click on “Insert a new row…” as seen below Scripted Rest API code snippet: 


      5. Create the following columns as Type string: 

  • sys_id 
  • vyopta_monitor_id 
  • vyopta_name 
  • vyopta_status 

Create a scripted Rest API 

  1. Go to “Scripted Rest API” in the ServiceNow Menu 
  2. Click the “New” button on the right hand side 
  3. Give the Scripted Rest API the name “Vyopta Webhooks” and hit submit 
  4. Once you hit submit, it exits the area, so search for “Vyopta Webhooks” and click on it to launch.  
  5. Click New under the resources tab as seen in the below image 


      6. Give the resource a name of “Incoming Vyopta Alerts” 

      7. Change the HTTP Method from “Get” to “Post” 

      8. Under the Security Tab, uncheck “Requires authentication” 

      9. Hit Save 

      10. Return to “Incoming Vyopta Alerts” and paste the following code: 

(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {

var requestBody = request.body;
var requestData =;
shortDescription =;
description = + " " + requestData.status + " " + requestData.category;

/* Need to lookup the DB first before creating an incident. */
var db = new GlideRecord('u_vyopta_alerts');
var query = 'u_vyopta_monitor_id=' + + '^' + 'u_vyopta_name=' +;

var issueBody = '[code]';
if(requestData.status === 'CRITICAL') {
issueBody += '<h2 style="text-align: center; color: red;">' + requestData.status + '</h2>';
} else if(requestData.status === 'WARN') {
issueBody += '<h2 style="text-align: center; color: orange;">' + requestData.status + '</h2>';
} else if(requestData.status === 'INFO') {
issueBody += '<h2 style="text-align: center; color: blue;">' + requestData.status + '</h2>';
} else if(requestData.status === 'CLEAR') {
issueBody += '<h2 style="text-align: center; color: green;">' + requestData.status + '</h2>';
} else {
issueBody += '<h2 style="text-align: center; color: purple;">' + requestData.status + '</h2>';

issueBody += '<table style="width: 50%;"><tbody>';
issueBody += '<tr><td>Name</td><td>'+ + '</td></tr>';
issueBody += '<tr><td>Description</td><td>'+ requestData.description + '</td></tr>';
issueBody += '<tr><td>Group</td><td>'+ + '</td></tr>';
issueBody += '<tr><td>Category</td><td>'+ requestData.category + '</td></tr>';
issueBody += '<tr><td>Metric</td><td>'+ requestData.metric + '</td></tr>';
issueBody += '<tr><td>Metric</td><td>'+ requestData.alertFiredTime + '</td></tr>';
issueBody += '</tbody></table>[/code]';

//Check if a record already exists
if( == true) {
//If record exists, get sys_id of ticket which is u_sys_id
var u_sys_id = db.getDisplayValue('u_sys_id');
var incLookup = new GlideRecord('incident');
incLookup.addQuery('sys_id', u_sys_id);

//If the status is has not changed - Update ticket with worknotes
if(requestData.status === 'CRITICAL' || requestData.status === 'WARN' || requestData.status === 'INFO') {
db.setValue('u_vyopta_status', requestData.status);
while( {
incLookup.work_notes = issueBody;
} else if (requestData.status === 'CLEAR') {
//If a clear message is sent, update worknotes with a clear message - Also have the ability to close ticket.
db.setValue('u_vyopta_status', requestData.status);
incLookup.addQuery('sys_id', u_sys_id);
while( {
incLookup.work_notes = issueBody;
} else {
//If the status is another status, update worknotes with info.
db.setValue('u_vyopta_status', requestData.status);
incLookup.addQuery('sys_id', u_sys_id);
while( {
incLookup.work_notes = issueBody;
} else {
//If record does not exist in u_vyopta_alerts table - Create a new incident and record it in the table
var grIncident = new GlideRecord('incident');

grIncident.impact = '2'; //Set the Impact
grIncident.urgency = '2'; //Set the Urgency
grIncident.short_description =; //Set Short Description of the ticket
grIncident.description = description; //Set the description of the ticket
grIncident.work_notes = issueBody; //Create a worknote if needed
var sys_id = grIncident.insert(); //Create incident and grab the sys_id of the ticket
db.setValue('u_vyopta_monitor_id',; //Set the Vyopta Monitor ID in u_vyopta_alerts table
db.setValue('u_vyopta_name',; //Set the Vyopta name in u_vyopta_alerts table
db.setValue('u_vyopta_status', requestData.status); //Set the status in u_vyopta_alerts table
db.setValue('u_sys_id', sys_id); //Set the ticket sys_id in the u_vyopta_alerts table

return 'Insert Into DB';

})(request, response);


You have now completed the Vyopta/ServiceNow integration! You should now see tickets appear once a monitor alert is triggered!


Was this article helpful?
0 out of 0 found this helpful



Please sign in to leave a comment.