ServiceNow Example
Send UXI data to your ServiceNow instance
Selecting the Generic HTTP Endpoint destination will send your test result data or issue data to your HTTP Endpoint database. For example, we are going to look at the ServiceNow instance. In addition, you can do more things in this SNOW scripted REST API like if the sensor is part of this group and reporting this type of issue, assign it to this team, etc, or assign different priorities for the issues. For example, maybe you care more about your own application than you do about some other app.
Once you configure your UXI dashboard to send issues to the Generic HTTP Endpoint, you can immediately start using the data to analyze the network and services.
Let's say you want to get all issues into the ServiceNow instance as Service Desk-Incidents then you can create the Scripted Rest API and create new resource and code will look like this:
(function process( /*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
gs.info(request.body.data);
var issues = request.body.data;
for (item=0; item<issues.length; item++){
var issue_uid = issues[item].uid;
var issue_code = issues[item].code;
var issue_snow_id = issue_code+'_'+issue_uid;
var issue_severity = issues[item].severity;
var issue_status = issues[item].status;
var issue_timestamp = issues[item].timestamp;
var issue_work_notes = issues[item];
var inc = new GlideRecord('incident');
if (issue_status == 'CONFIRMED') {
inc.initialize();
inc.work_notes = JSON.stringify(issue_work_notes);
inc.short_description = issue_snow_id; // set this to identify the incident later for resolved messages
inc.insert();
gs.info('Incident created');
return {
"status": "CONFIRMED",
"uri": request.uri,
"url": request.url,
"sys_id": inc.sys_id,
};
} else if (issue_status == 'RESOLVED') {
inc.get("short_description", issue_snow_id);
inc.state = 7;
inc.update();
gs.info('Incident closed');
return {
"status": "RESOLVED",
"uri": request.uri,
"url": request.url,
"sys_id": inc.sys_id,
};
}
}
}
)(request, response);
Updated over 2 years ago
For more information, you can refer to our help article here