Ticket Forwarding

With ticket forwarding enabled, the plugin creates and updates incidents in ServiceNow through the Incident Table API (/api/now/table/incident). The ticketer plugin must be enabled in OpenNMS, see Installation. To create a case instead of an incident for some tickets, set a case filter.

  • A new OpenNMS ticket creates an incident. The sys_id of the incident becomes the ticket ID.

  • An updated or closed ticket updates the incident.

  • The alarm severity sets the impact and the urgency of the incident.

  • A resolved incident gets the close code and close notes.

  • When the node label matches a configuration item in the ServiceNow CMDB, the incident links to it.

  • Work notes hold the OpenNMS context: node label, node ID, IP address and alarm ID.

Ticket Filter

The ticket filter selects the alarms that can create an incident. It is a JEXL expression on the alarm and on its ticket. An empty filter, the default, lets every alarm create an incident.

Example: incidents for threshold alarms and node down alarms only
alarm.reductionKey =~ 'uei.opennms.org/threshold/.*' or alarm.reductionKey =~ 'uei.opennms.org/nodes/nodeDown.*'

All alarm filter fields are available, plus these ticket fields:

Table 1. Ticket fields
Field Description

ticket.ipAddress

Interface IP address

ticket.nodeId

Node ID

ticket.user

Ticket user

ticket.attributes

Custom attributes, a map

Example: filter by IP address
alarm.reductionKey =~ 'uei.opennms.org/threshold/.*' and ticket.ipAddress =~ '192.168.1.*'

Incident Mapping

Incident field Source

short_description

Node label and alarm log message, for example mynode: OpenNMS: High threshold exceeded

description

Alarm description

caller_id

Ticket user, when set

state

Ticket state: OPEN is 1 (New), CLOSED is 6 (Resolved), CANCELLED is 8 (Cancelled)

impact

From the alarm severity, see the table below

urgency

From the alarm severity, see the table below

correlation_id

OpenNMS:Alarm:<alarmId>

category

Network, set by the default field mapping, see Incident Field Mappings

cmdb_ci

The sys_id of the configuration item whose name equals the node label

work_notes

OpenNMS context: instance ID, node label, node ID, IP address, alarm ID

close_code

The configured close code, sent on resolve, see Incident Close Code

close_notes

Resolved via OpenNMS alarm lifecycle. OpenNMS Alarm ID: <id>

You can change these values and set more incident fields with Incident Field Mappings.

Impact and Urgency

Alarm severity Impact Urgency

CRITICAL

1 (High)

1 (High)

MAJOR

1 (High)

2 (Medium)

MINOR

2 (Medium)

2 (Medium)

WARNING

2 (Medium)

3 (Low)

Other

3 (Low)

3 (Low)

Incident State to Ticket State

When the plugin reads an incident, it maps the state like this:

Incident state Ticket state

1 (New), 2 (In Progress), 3 (On Hold)

OPEN

6 (Resolved), 7 (Closed)

CLOSED

8 (Cancelled)

CANCELLED

Incident Field Mappings

Field mappings set columns of the incident when the plugin creates it. The default mapping is one rule that sets category to Network. The mappings are a JSON document. You can type it, load it from a file, or restore the default.

The plugin does not limit the column names. Do not map state or correlation_id. The plugin sets these fields and uses them to track the incident. Common uses:

  • Routing: assignment_group, assigned_to

  • Classification: category, subcategory, business_service, service_offering

  • Priority: impact, urgency, to replace the values from the severity

  • People: caller_id, opened_by

  • Content: short_description, description, work_notes, to replace the text the plugin builds

  • Custom columns: u_* columns added by your ServiceNow administrators, or x_* columns from scoped applications

Use the column name, not the form label. ServiceNow adds the prefix u_ to columns that an administrator creates. A field with the label "Contact Number" is usually the column u_contact_number. To find the name, right-click the field label on the incident form in ServiceNow and select Configure Dictionary. The column must exist on the table. ServiceNow ignores a column it does not know, without an error.

The mappings are a JSON array of rules:

[
  {
    "fields": {
      "assignment_group": "Network Operations",
      "u_contact_number": "555-0100"
    }
  },
  {
    "name": "lab nodes",
    "filter": "alarm.node.location == 'Lab'",
    "fields": {
      "assignment_group": "Lab Support"
    }
  }
]

Each rule has:

  • fields, required: a map of column name to value.

  • filter, optional: a JEXL condition with the same context as the Ticket Filter. A rule without a filter applies to every incident.

  • name, optional: a label for the error messages.

The plugin applies every rule whose filter matches, in the given order. A later rule replaces the value of an earlier one. The example sets a default assignment group and replaces it for the nodes in the Lab location.

The plugin writes a default filter or mapping only at the first start, when the setting does not exist. A value that you clear and save stays empty after a restart. To get a default back, restore the default and save.

A value can contain JEXL expressions in ${…​}:

[{"fields": {"u_node_label": "${alarm.node.label}", "u_source": "OpenNMS ${alarm.node.location}"}}]

A value that is one expression with the result null keeps the field as it is. An example is ${alarm.node.label} for an alarm without a node. So missing alarm data cannot clear a field that the default mapping or an earlier rule set. To clear a field, give it the JSON value null:

[{"filter": "alarm.node.location == 'Lab'", "fields": {"cmdb_ci": null}}]

An expression ends at the first }. Do not use JEXL map or set literals inside ${…​}, because they contain }.

Values for Filters and Expressions

Rule filters and ${…​} expressions use the same context as the Ticket Filter. The alarm object is the Integration API alarm, ticket is the OpenNMS ticket.

Expression Value

alarm.id, alarm.reductionKey

Alarm ID and reduction key

alarm.severity.label, alarm.severity.name(), alarm.severity.id

Severity as label (Critical), as name (CRITICAL) or as number (7)

alarm.logMessage, alarm.description

Alarm texts

alarm.type.name()

PROBLEM, RESOLUTION or PROBLEM_WITHOUT_RESOLUTION

alarm.managedObjectType, alarm.managedObjectInstance

Managed object

alarm.firstEventTime, alarm.lastEventTime

Times

alarm.lastEvent.uei

UEI of the last event

alarm.attributes

Alarm attributes, a map

alarm.situation, alarm.acknowledged

True or false

alarm.node.id, alarm.node.label

Node ID and label

alarm.node.foreignSource, alarm.node.foreignId

Requisition name and foreign ID

alarm.node.location

Monitoring location

alarm.node.categories

List of node category names

alarm.node.metaData

Node metadata entries

alarm.node.assetRecord

Asset record, for example alarm.node.assetRecord.city

ticket.ipAddress, ticket.nodeId, ticket.user

Values of the OpenNMS ticket

ticket.attributes

Ticket attributes, a map

Examples:

[
  {"fields": {"u_requisition": "${alarm.node.foreignSource}"}},
  {"filter": "alarm.node.categories.contains('Production')", "fields": {"urgency": "1"}},
  {"filter": "alarm.node.foreignSource == 'customer-a'", "fields": {"assignment_group": "Customer A Desk"}}
]

ServiceNow sets the rules for the values, not the plugin:

  • A reference field, such as assignment_group or caller_id, must match a record in ServiceNow. You can give the sys_id or the display value, for example "assignment_group": "Network". A display value must match one record. Use the sys_id when names repeat.

  • A choice field, such as category, must match a configured choice. ServiceNow ignores or rejects a value that does not match.

  • The integration user must have write access to the field. ServiceNow ACLs apply to API writes in the same way as to form edits.

  • Field mappings apply only when the plugin creates an incident. An update changes only the state and the close fields, so a mapped short_description or description stays.

Incident Close Code

When the plugin resolves an incident, after an alarm clear or a ticket close in OpenNMS, it sends the configured close code. The default is Solution provided, the value that earlier plugin releases always sent. Close codes differ between ServiceNow releases and instances. Zurich, for example, has no Solution provided.

The close code setting lists the close codes of the connected instance. Select the one your instance uses for a fix by the monitoring system. The plugin reads the list with the integration user. No additional role is necessary. When the stored close code is not on the instance, the plugin shows a warning at the ticket forwarding setting and at the close code setting. Resolves fail until you select a code. The ticket log then shows the ServiceNow reply, for example Data Policy Exception: Resolution code mandatory.

To list the close codes with the REST API, use an admin user. The sys_choice table is closed to the itil role:

curl -u 'admin:<password>' \
  "https://<your-instance>.service-now.com/api/now/table/sys_choice?sysparm_query=name=incident^element=close_code^inactive=false&sysparm_fields=label"

While ticket forwarding is enabled, the ticket ID on the OpenNMS alarm detail page links to the ServiceNow record (<instance-url>/task.do?sys_id=<ticket-id>). ServiceNow opens an incident or a case in the form of its own table. The plugin sets the link template from the instance URL. You do not need to edit opennms.properties. When you disable ticket forwarding, the plugin removes the link.

Automated Ticketing with Alarm Rules

The plugin gives the ServiceNow integration. Automatic ticket creation and closure need the Drools alarm rules of OpenNMS. Without these rules, a user creates and closes tickets in the OpenNMS UI or through the REST API.

OpenNMS has ticketing rules in $OPENNMS_HOME/etc/alarmd/drools-rules.d/alarmd.drl. They are disabled by default. To enable a rule, change enabled false to enabled true in the rule and restart OpenNMS.

Rule Function Timing

createTickets

Creates an incident for a problem alarm and acknowledges the alarm. This is the main rule for automatic tickets.

15 min after the alarm is stable

createCriticalTicket

Creates an incident for a CRITICAL alarm after a shorter wait.

5 min after the alarm is stable

closeClearedAlarmTickets

Closes the incident when the alarm clears in OpenNMS.

15 min after the clear

updateTickets

Reads the incident state from ServiceNow and updates the ticket state in OpenNMS.

Every 15 min

clearAlarmsForClosedTickets

Clears the alarm in OpenNMS when the incident is resolved or closed in ServiceNow.

At once

For most installations, enable all five rules:

  • createTickets: automatic incident creation

  • closeClearedAlarmTickets: automatic incident closure when the alarm clears

  • updateTickets and clearAlarmsForClosedTickets: an incident resolved in ServiceNow clears the alarm in OpenNMS

The updateTickets rule reads the incident and maps the state as in Incident State to Ticket State.