User Tools

Site Tools


observer_beginners_guide

Observer for ServiceNow Startup Guide

Dubnium

Perspectium Observer is an analytics tool that monitors, aggregates into trends, and provides alerts on metrics supplied by your ServiceNow instance in real time. To install Observer, you will need to request the Perspectium Update Set for ServiceNow and the Observer Update Set for ServiceNow from support@perspectium.com.

After previewing and committing both update sets:

  1. In ServiceNow, navigate to Perspectium > Observer > Observer UI. NOTE: If you are unable to see the Observer UI, check your browser's settings to make sure that you are allowing popups from ServiceNow.com.
  2. If you are logging in for the first time, follow the steps for Navigating the Observer Tour. Otherwise, continue to the Observer Homepage.

When you visit the Observer homepage for the first time, a tour of the observer will begin. The observer tour provides basic information about the observer. Click the “next” or “back” button to navigate the tour. Click the “skip” button or click anywhere outside of the tour's information box to end the tour. The tour will only occur the first time the user visits the observer.

Helpful Tips


Here you will find some tips and tricks to help you use the Observer for the first time. For any questions, please contact support@perspectium.com

ServiceNow Instance Attributes

Share External Events to Monitor in Observer

Custom external events can be posted directly to Observer for monitoring. The following is an example using python and the AMQP python client (http://www.rabbitmq.com/devtools.html):

1. Create a method that will post the flag to Observer

#!/usr/bin/env python
import pika

credentials = pika.PlainCredentials('username','password')
connection = pika.BlockingConnection(pika.ConnectionParameters('instance-amqp.perspectium.net',5672,'/',credentials))
channel = connection.channel()
channel.queue_declare()
channel.basic_publish(exchange='',routing_key='psp.in.servicenow',body='{ topic:"monitor", type:"statsx", key:"demo005", name:"transaction_sec", value: "1423"}')

connection.close()

How to Monitor an Integration using a Custom Flag

Custom Flags can be posted to Observer to mark an integration event such as success or failure. These flags can be used to alert as well. The following is an example using python and the AMQP python client (http://www.rabbitmq.com/devtools.html):

1. Create a method that will post the flag to Observer

#!/usr/bin/env python

import pika
import sys
import socket
import os
import time

def postFlag():
	credentials = pika.PlainCredentials('username','password')
	connection = pika.BlockingConnection(pika.ConnectionParameters('instance-amqp.perspectium.net',5672,'/',credentials))
	channel = connection.channel()
	channel.queue_declare()
	channel.basic_publish(exchange='',routing_key='psp.in.servicenow',body='{ topic:"monitor", type:"label", key:"perspectiumdemo1", name:"integration.failed", value: "1"}')
	connection.close()

2. Call the postFlag() method in a try/catch block:

try:
    soapMethodToServiceNow();
except Exception e:
    print "Integration failed, posting integration flag to Observer"
    postFlag()

3. Create the Custom Alert in Observer

4. Observe!

Note: The Highcharts Range Selectors can be used to render data from a custom date.


Custom Monitoring with a Perspectium Action

In ServiceNow, you can create your own Perspectium Action to do custom monitoring and send in your own events. For example, you may want to monitor the total number of tasks created daily.

You can do this by leveraging the PerspectiumObserver script include that comes as part of the Perspectium Observer update set. The following functions are available for use in the script include:

postTuple: function (type, name, value)

postDailyTableAggregates: function (tableName, eventName, aggField)

postTableAggregates: function (tableName, eventName, aggField, encodedQuery)

postSecondsAgoTableAggregates: function (tableName, eventName, aggField, fromDateStr, secondsAgo)

Go to Observer > Actions and create a new record. Give the record a name, make it active, enter when it should execute and then script to execute what you're trying to monitor, leveraging the PerspectiumObserver script include to create messages with the data that can be sent to Observer. Each time this action is run, This will then send the data as a metric to Observer.

For example, below is a custom action for monitoring the number of tasks created daily and uses the PerspectiumObserver's postTuple() function:

try {
    var psp = new Perspectium();
    var o = new PerspectiumObserver();
	
    // Calculate total number of tasks created today 
    var sc = new GlideRecord('task');
    sc.addEncodedQuery('sys_created_onONToday@javascript:gs.daysAgoStart(0)@javascript:gs.daysAgoEnd(0)');
    sc.query();

    // postTuple() is a function that can be called to create messages with metrics to send to Observer
    // it should be passed the parameters "statsx", name of the	metric, value of the metric
    o.postTuple("statsx", "Tasks Created Today", sc.getRowCount());
} catch (e) {
    var logger = new PerspectiumLogger();
    logger.logError("error= " + e, "Action.Tasks Created Today");
    psp.updateStatus("status", "error: " + e);
}

This data will be send to Observer and can be trended in the UI.
You can also create a custom alert for it in the Alert Configurations tab:

This alert will show in the main Monitor page:

Table Indexes

As of v3.19.0, these indexes are included as part of the update set. However, these indexes will only install properly in Helsinki+ versions of ServiceNow and will show commit errors in older versions. These commit errors can be ignored as the rest of the update set commits will have installed properly.

Table Type Fields
PSP Observer Out Message (u_psp_observer_out_message) composite, non-unique State (u_state)
Created (sys_created_on)
PSP Observer Out Message (u_psp_observer_out_message) single, non-unique Created (sys_created_on)
PSP Observer Out Message (u_psp_observer_out_message) single, non-unique Sequence (u_sequence)
PSP Observer Out Message (u_psp_observer_out_message) composite, non-unique Created (sys_created_on)
Sequence (u_sequence)
User (sys_user) single, non-unique Active (active)
User (sys_user) single, non-unique Source (source)

Getting alerted to slower-than-expected transactions

1) Create an event named, for example, “slow.transaction” in the ServiceNow event registry

2) Create a scheduled job to identify slow transactions - the example below is basic; you could certainly create something more elaborate via, for example, a custom table, which would have the name of the job, and the number of milliseconds after which the event should fire, etc.

// 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);
}

3) Create an Event Subscription (under Observer menu) to send those events, when they trigger, to Observer:

4) The events will then show up in the Events list at the bottom of the main Observer page (you can also set an alert for it in the Observer Settings page, under Alert Configurations > Events):

observer_beginners_guide.txt · Last modified: 2018/10/04 15:28 by timothy.pike