Procedure


(warning) This is an advanced procedure that requires knowledge of scripting with ServiceNow APIs.

To create an event for slow transactions, follow these steps:

1. Log into ServiceNow. In the Filter Navigator on the upper left-hand side of the screen., type Scheduled Jobs and navigate to the Scheduled Jobs module under Perspectium > Observer.

2. At the top of the Scheduled Jobs form, click New to create a new Scheduled Job.

3. Type a name for your new Scheduled Job and make sure the Active box is checked. Then, scroll to the scripting section and type your script for the new job. Once you are done typing the script for your new Scheduled Job, click Submit

Below is an example of a script that could be used to create a new Scheduled Job for Observer called slow.transaction. For more information about creating scripts for Perspectium Jobs in ServiceNow, see the ServiceNow API Reference Guide.

// Identify any instance within the last 15 minutes of the job "JOB: Perspectium MultiOutput Processing" running longer than 1000; output one event per instance found
var gr = new GlideRecord("syslog_transaction");
gr.addEncodedQuery("type=scheduler^url=JOB: Perspectium MultiOutput Processing^sys_created_onONLast 15 minutes@javascript:gs.minutesAgoStart(15)@javascript:gs.minutesAgoEnd(0)");
gr.addQuery("response_time", ">", 1000);
gr.query();
while(gr.next()){
    var msg = "Job " + gr.url + "(" + gr.sys_id + ") is taking too long: " + gr.response_time + " ms";
    gs.eventQueue('slow.transaction', current, msg);
}

4. In ServiceNow's left side navigation window, type Event Subscription and navigate to the Event Subscription module under Perspectium > Observer. Then, click New to create a new Event Subscription.

5. Type a name for your new Event Subscription next to Event. For the script section, add your script according to the example below. Then, click Submit.

answer = event.param1 + "|" + event.param2