ServiceNow integration with OpsRamp is a bi-directional integration. OpsRamp provides the following two types of integration with ServiceNow:
- Incident Integration:
View an OpsRamp incident in ServiceNow (and vice versa). - CMDB Integration: Integrate OpsRamp Resources with third-party Configuration Item (CI) entities.
The document describes how to complete ServiceNow Integration for inbound and outbound configurations. Inbound or outbound configurations can be created separately.
ServiceNow incident management integration
Using incident integration, an OpsRamp incident can be viewed in ServiceNow (or vice versa).
Prerequisite
Configure the Service Desk priority matrix. For details, view how to manage Service Desk.
OpsRamp configuration
This section describes the configuration steps for ServiceNow Incident management integration.
From All Clients, select a client.
Go to Setup > Account.
Select the Integrations and Apps tab.
The Installed Integrations page, where all the installed applications are displayed. Note: If there are no installed applications, it will navigate to the Available Integrations and Apps page.
Click + ADD on the Installed Integrations page. The Available Integrations and Apps page displays all the available applications along with the newly created application with the version.
Search for the application using the search option available. Alternatively, you can use the All Categories option to search.
Click ADD in the ServiceNow application and click Install.
From the Inbound Configuration tab, do the following:
- In the Authentication section:
- Select authentication type as OAuth2 and click Save.
- Take note of the Tenant ID, Key and Secret.
These details are used in ServiceNow to create the OAuth provider.
- Click Save.
- In the Authentication section:
From the Outbound Configuration tab, do the following:
- In the Integration Basic Configuration section, enter the following and Save.
Configure basic notification details to trigger events defined:
- Notification type: REST API
- Base URI:
https://{servicenow-subdomain}.com
.
For example:https://demo.servicenow.com
- Authentication type: OAuth2
- Grant Type: Password Credentials
- Access Token:
URL:https://{servicenow-subdomain}.com/oauth_token.do
For example:https://demo.servicenow.com/oauth_token.do
- Add Key, Secret, Username and Password.
- In the Integration Event section, perform the following steps to create an integration event:
- Click +Add. The Add Event page is displayed.
- Enter a name for the integration event.
- Select the Entity, Entity Type, and Entity type event from the drop-down lists.
Advanced Settings (Optional): Click on the down arrow and click on +Add. Provide the property, Operator, and Value as filters. Click on Save.
Actions:
- Select the Use parent configuration option to inherit parent configuration.
- Enter the End Point URL.
- Select the Notification Type. Available options are REST API and SOAP API.
- Select the Authentication Type. Based on the Notification Type selected, the Authentication Type differs. Available options are Basic, OAuth2, JWT, None.
- Select the Web Method and enter the Headers and Payloads.
Response: Enter the Key and Value in the fields and click Save.
Attachment (Optional): Enter the details: Process Type, Attachment Endpoint URL, and Web Method.
Attachment Headers:- Select the Name and enter the Value and click Save.
- Enter the Attachment Payload in the field.
- Enter the Key and Value under Attachment Response.
- Click Add Event.
You can perform actions on the created event. See Actions on an Event for more information.
- A custom field already configured as response payload attribute for a given integration is not available for configuration in any other integrations. Remove the existing mapping from the integration to make the custom field available for mapping in the response payload from any other integration.
- To parse the properties returned in response for the configured API payload, select the property from the drop-down menu and enter the value.
Integration response mapping configuration:
Response mapping configuration is mainly based on the response payload that is received in third party payload; below are a few examples for response mapping configuration -
- sample response payload to mapping the id in response mapping:
{ "id":"INC0001", "type":"incident", "tool":"servicedesk" }
external ticket id = $id
We need to append $ to the value- sample response payload to mapping the id in response mapping:
{ "result":{ "id":"INC0001", "type":"incident", "tool":"servicedesk" } }
external ticket id = $result.id
- Sample response payload to mapping the id in response mapping
{ "result":[ { "ticketDetails":{ "id":"INC0001", "type":"incident", "tool":"servicedesk" }, "Description":{ "display_value":"testing description", "value":"validating" } } ] }
external ticket id = $result[0].ticketDetails.id
- sample response payload to mapping the Incident Number in response mapping
{ "result": { "Incident Number": "INC0001", "type": "Incident" } }
external ticket id = $result[‘Incident Number’]
Failures
You can configure integration failures only when modifying the integration.
To configure integration failure:- Click Add under Failures and enter the following information:
1. Select Notify type as Email.
2. Enter the email addresses in To and CC fields, and click Add Failure Notifications.
In case of an integration failure, an Email is sent to the respective user.
- Click Add under Failures and enter the following information:
- In the Integration Basic Configuration section, enter the following and Save.
Configure basic notification details to trigger events defined:
Click Finish.
Actions on an Event
You can perform the following actions on an event:
- Copy Id: To copy the Event Id.
- Edit: To update the event.
- Save as: Copy of an event. Use this copy to create another event.
- Validate: Validate if the event is successful. Enter the details: JSON or Form and click Validate. A success response is generated if the event is successful.
- Remove: To remove the event.
Integration event payloads
Refer to the integration event payload below to create an incident in ServiceNow.
Create incident in ServiceNow
Fields | Values |
---|---|
Endpoint URL | https://{subdomain}.com/api/now/import/u_opsramp_incident |
Headers |
|
Method | POST |
Example request
{
"u_caller_id": "6816f79cc0a8016401c5a33be04be441",
"u_status": "$incident.status.name",
"u_impact": "$incident.businessImpact.name",
"u_urgency": "$incident.urgency.name",
"u_subject": "$incident.subject",
"u_description": "$incident.impact",
"u_opsramp_incident_id": "$incident.uniqueId"
}
Example response
{
"import_set": "ISET0013148",
"staging_table": "u_opsramp_incident",
"result": [{
"transform_map": "OpsRamp Incident Trans Map",
"table": "incident",
"display_name": "number",
"display_value": "INC0979030",
"record_link": "https://{subdomain}.com/api/now/table/incident/c4372d5e0f971200500c00dce1050e56",
"status": "inserted",
"sys_id": "c4372d5e0f971200500c00dce1050e56"
}]
}
ServiceNow configuration
ServiceNow Kingston version supports OAuth2 authentication with Basic authentication.
Configuring the OpsRamp API in ServiceNow involves the following:
- Configuring Custom Fields
- Configuring OAuth
- Configuring REST Message
- Configuring Import Set
- Configuring Transform Map
- Configuring Business Rule
Configure custom fields
Create the custom fields as below:
- OpsRamp Incident ID custom field
- OpsRamp Client ID custom field
OpsRamp Incident ID custom field
A custom field needs to be created in the ServiceNow incident table to save the OpsRamp Incident ID as a ServiceNow incident.
To create an OpsRamp Incident ID custom field:
- Log into ServiceNow.
- Click All from the menu and search for System Definition and under that, click Dictionary.
- Select New to create a new field.
- Enter the following details:
- Table: Select Incident[incident] table
- Application: Default value
- Type: Select String
- Active: Active
- Column label: Enter a name to the custom field (Example: OpsRamp Incident ID)
- Function Field: Default value
- Column name: Auto-generated if Column label is provided
- Read only: Default value
- Max length: 64
- Mandatory: Default value
- Display: Default value
- Click Submit to save details.
- Configure Form Layout to ensure that OpsRamp Incident ID column is visible in the Incident form.
OpsRamp Client ID custom field
Create a custom field (OpsRamp Client ID) in the ServiceNow Company table to save the OpsRamp Client ID.
- Create custom field (OpsRamp Client ID) if integration is performed at OpsRamp Partner level.
- If integration is performed at the client level, the OpsRamp Client ID does not need to be configured.
To create an OpsRamp Client ID custom field:
- Click System Definition on the left pane and click Dictionary.
- Select New to add a field.
- Enter the required details:
- Table: Select
Company[core_company]
table - Application: Default value
- Type: Select
String
- Active: Active
- Column label: Enter a name to custom field (Example: OpsRamp Client ID)
- Function Field: Default value
- Column name: Auto-generated if the Column label is provided
- Read only: Default value
- Max length: 64
- Mandatory: Default value
- Display: Default value
- Table: Select
- Click Submit to save details.
- Configure Form Layout to ensure that OpsRamp Client ID is visible in the Company form.
After creating the OpsRamp Client ID custom field, update the OpsRamp client ID column for each company in ServiceNow.
Configure OAuth
The process of configuring OAuth in ServiceNow involves the following steps:
- Create a user account
- Configure the OAuth profile:
- Create an OAuth client
- Create an OAuth provider
Create a user account
To create a user account:
- Click Organization on the left pane and click Users.
- Select New to add a user.
- Enter the user details and click Submit.
- In the User profile, click the Roles tab, and click Edit.
- Select the roles required (rest_service and web_service_admin).
- Click Done.
Configure OAuth profile
Validate if OAuth2 plugin is Active.
- Click System Definition on the left pane and click Plugins.
- Verify the status of the OAuth2 plugin.
Creating the OAuth client is a prerequisite to generate the Client ID and the Client Secret.
Both fields are required to configure the ServiceNow authentication details.
To create an OAuth client:
- Click System OAuth on the left pane and click Application Registry.
- Click New to add an Application Registry.
- Click Create an OAuth API endpoint for external client.
- Enter the following details in the Application Registries page:
- Name: Enter a name (Example: SNOW OAuth2Client)
- Application: Default value -Global
- Client ID: Auto-generated
- Accessible from: Default value - All application scopes
- Client Secret: Auto-generated
- Active: Select Active
- Refresh Token Lifespan: Default value - 8,640,000
- Access Token Lifespan: Default value - 1800
- Redirect URL: Optional
- Logo URL: Optional
- Comments: Enter comments about the client.
Example: SNOW OAuth2client details required for OpsRamp to call SNOW APIs
- Click Submit.
Before configuring OpsRamp OAuth details to call APIs from ServiceNow, configure the OAuth provider.
Do the Inbound Configuration in OpsRamp before creating the OAuth provider.
To configure the OAuth provider:
- Click All from the menu and search for System OAuth and under that, click Application Registry.
- Click New from the Application Registry drop-down menu.
- Click Connect to a third party OAuth provider.
- Enter the details in Application Registries page:
- Name: Give a name
Example:OpsRamp OAuth2 Provider
- Application: Default value - Global
- Client ID: Enter OpsRamp OAuth2 key
- Accessible from: Default value - All application scopes
- Client Secret: Provide OpsRamp OAuth2 secret
- Active: Select Active
- OAuth API Script: Optional
- Authorization URL: Optional
- Logo URL: Optional
- Token URL: Enter OpsRamp OAuth token URL as
https://{Your OpsRamp domain}/auth/oauth/token
Example:https://api.opsramp.com/auth/oauth/token
- Default Grant Type: Select Client Credentials
- Token Revocation URL: Optional
- Refresh Token Lifespan: Optional - 7200
- Redirect URL: Optional
- Comments: Enter SNOW OAuth2 client details required for OpsRamp to call SNOW APIs.
- Name: Give a name
- Click Submit to save the details.
Configure a REST message
Configure REST messages before configuring the OpsRamp API details. REST messages can be invoked with a business rule script when certain configuration conditions are met.
Configuring a REST message involves the following steps:
- Configure a REST message
- Configure a REST message using the HTTP method:
- Create Incident HTTP method
- Update Incident HTTP method
To configure a REST message
- Log into ServiceNow.
- Click All from the menu and search for System Web Services and under that, click REST Message.
- Select New to create a REST message.
- Enter details for the REST message:
- Name: Provide a name for the REST message. This name is required in business rule script
Example: OpsRamp Create Incident - Application: Default value - Global
- Accessible from: Default value - This application scope only
- Description: Enter description about REST message
Example: Rest message to call OpsRamp create incident API - Endpoint: <https://{your OpsRamp domain}>
Example:https://api.opsramp.com
- Authentication:
- Authentication type: Select OAuth 2.0
- OAuth profile: Search profiles and select OAuth provider profile created in the OAuth section
Example: OpsRamp OAuth2Provider default profile
- HTTP Request: No configurations required
- Name: Provide a name for the REST message. This name is required in business rule script
- Click Submit to save the details.
To learn more about APIs, see Getting Started.
Configure REST message HTTP method
After creating a REST message, the following HTTP methods can be created to configure OpsRamp create/update incident API details.
- Create an incident HTTP method
- Update an Incident HTTP method
Step 1: Create an incident HTTP method
- Click New on the HTTP method page.
- Enter details in HTTP Method page.
- REST Message: Auto populates OpsRamp Create Incident REST
- Application: Default value - Global
- Name: Provide a name (Example: Create Incident)
- HTTP Method: Select POST
- Endpoint:
https://{your OpsRamp domain}/api/v2/tenants/${tenantId}/incidents
Example:https://api.opsramp.com/api/v2/tenants/${tenantId}/incidents
- Authentication: Authentication type: Select
Inherit from Parent
. As authentication details are already configured in the REST message, its details are inherited.
- Click Submit.
The placeholder in Endpoint
is replaced in the business rule script.
HTTP request
Fields | Values |
---|---|
HTTPS Headers | Create Content-Type header
|
HTTP Query Parameters | Provide OpsRamp create incident payload |
Example payload
{
"subject": "${subjectToken}",
"description": "${descriptionToken}",
"priority": "${priorityToken}",
"extTicketId": "${extTicketIdToken}"
}
Step 2: Update an incident HTTP method
To configure OpsRamp update incident API:
- Click New on the HTTP method page.
- Enter following details:
- REST Message: Automatically populates OpsRamp Update Incident REST
- Application: Default value - Global
- Name: Enter a name (Example: Update Incident)
- HTTP Method: Select
POST
- Endpoint:
https://{your OpsRamp domain}/api/v2/tenants/${tenantId}/incidents/${incidentId
}
For example:https://api.opsramp.com/api/v2/tenants/${tenantId}/incidents/${incidentId}
) - Authentication: Authentication type: Select
Inherit from Parent
. As authelssage, its details are inherited.
- Click Submit.
The placeholder in Endpoint
is replaced in the business rule script.
HTTP Request
Fields | Values |
---|---|
HTTPS Headers | Create Content-Type header
|
HTTP Query Parameters | Provide OpsRamp update incident payload |
Example payload
{
"priority": "${priorityToken}",
"status": "${statusToken}",
"response": {
"description": "${responseToken}"
}
}
Configure import set
Import sets allow user to import data from various data sources and map the data into ServiceNow tables. To create a staging table to save OpsRamp incident columns, do the following:
- Create a table
- Create table columns
Create a table
To create a table:
- Click All from the menu and search for System Definition and under that, click Tables.
- Select New to create a table.
- Fill required details:
- Label: Enter a label to the table
Example: OpsRamp Incident - Application: Default value
- Name: Auto-generated when if a label is provided
- Create module: Default value
- Create mobile module: Default value
- Add module to menu: Default value
- Extends table: Select
Import Set Row
- Label: Enter a label to the table
- Click Submit to save table.
Create table columns
To create table columns:
- Select the created table name (OpsRamp Incident[u_opsramp_incident]) from the Table drop-down menu.
- On the Columns tab, click New to create a table column. The following fields are required (more columns can be added as needed):
Column Label | Table | Application | Type | Active | Function Field | Column name | Read only | Max Length | Mandatory | Display |
---|---|---|---|---|---|---|---|---|---|---|
Caller ID | OpsRamp Incident[u_opsramp_incident] | Default Value | String | Active | Default Value | Auto-generated value | Inactive | 32 | Active | Inactive |
Description | OpsRamp Incident[u_opsramp_incident] | Default Value | String | Active | Default Value | Auto-generated value | Inactive | 4000 | Active | Inactive |
Impact | OpsRamp Incident[u_opsramp_incident] | Default Value | String | Active | Default Value | Auto-generated value | Inactive | 32 | Active | Inactive |
OpsRamp Client ID | OpsRamp Incident[u_opsramp_incident] | Default Value | String | Active | Default Value | Auto-generated value | Inactive | 64 | Active | Inactive |
OpsRamp Incident ID | OpsRamp Incident[u_opsramp_incident] | Default Value | String | Active | Default Value | Auto-generated value | Inactive | 64 | Active | Inactive |
Status | OpsRamp Incident[u_opsramp_incident] | Default Value | String | Active | Default Value | Auto-generated value | Inactive | 32 | Active | Inactive |
Subject | OpsRamp Incident[u_opsramp_incident] | Default Value | String | Active | Default Value | Auto-generated value | Inactive | 160 | Active | Inactive |
Urgency | OpsRamp Incident[u_opsramp_incident] | Default Value | String | Active | Default Value | Auto-generated value | Inactive | 32 | Active | Inactive |
Work Notes | OpsRamp Incident[u_opsramp_incident] | Default Value | String | Active | Default Value | Auto-generated value | Inactive | 4000 | Inactive | Inactive |
An example set of table columns:
Configure transform map
Configuring the transform map involves the following steps:
- Creating a transform map.
- Configuring field maps.
Create transform map
A transform map is a set of field maps that determines the relationships between fields in an import set and fields in an existing ServiceNow table. The relationship between the staging table created using import sets needs to be defined with the incident table.
To create a transform map:
- Click System Import Sets on the left pane and click Transform Maps.
- Select New to create a Transform Map.
- Enter the required details:
- Name: Enter a name to transform map
Example: OpsRamp Incident Trans Map - Created: Default value
- Source table: Select staging table created (
OpsRamp Incident[u_opsramp_incident]
) - Target table: Select
incident[Incident]
- Active: Active
- Order: Default value
- Run business rules: Active
- Run script: Active. Place
INC_Trans_map_script.js
in the script field - Enforce required fields: Select
No
- Copy empty fields: Default value
- Name: Enter a name to transform map
- Click Submit to save the details.
Configure field maps
After creating Transform Map, configure field maps for each column in the staging table
u_opsramp_incident
with the incident table.
To configure field maps:
- Select the transform map created (OpsRamp Incident Trans Map) from the Map drop-down menu.
- Click New on the Field Maps page.
- Create map for the following columns:
Map | Source Table | Target Table | Source Field | Target Field | Coalesce | Use Source Script |
---|---|---|---|---|---|---|
OpsRamp Incident Trans Map | OpsRamp Incident[u_opsramp_incident] | incident | Subject (u_subject) | Short Description (short_description ) | Inactive | Inactive |
OpsRamp Incident Trans Map | OpsRamp Incident[u_opsramp_incident] | incident | Description (u_description) | Description (description) | Inactive | Inactive |
OpsRamp Incident Trans Map | OpsRamp Incident[u_opsramp_incident] | incident | Status (u_status) | State (state) | Inactive | Inactive |
OpsRamp Incident Trans Map | OpsRamp Incident[u_opsramp_incident] | incident | Impact (u_impact) | Impact (impact) | Inactive | Inactive |
OpsRamp Incident Trans Map | OpsRamp Incident[u_opsramp_incident] | incident | Urgency (u_urgency) | Urgency (urgency) | Inactive | Inactive |
OpsRamp Incident Trans Map | OpsRamp Incident[u_opsramp_incident] | incident | Caller ID (u_caller_id) | Caller ID (u_caller_id) | Inactive | Inactive |
OpsRamp Incident Trans Map | OpsRamp Incident[u_opsramp_incident] | incident | OpsRamp Incident ID (u_opsramp_incident_id) | OpsRamp Incident ID (u_opsramp_incident_id) | Active | Inactive |
OpsRamp Incident Trans Map | OpsRamp Incident[u_opsramp_incident] | incident | OpsRamp Client ID (u_opsramp_client_id) | OpsRamp Client ID (u_opsramp_client_id) | Inactive | Inactive |
OpsRamp Incident Trans Map | OpsRamp Incident[u_opsramp_incident] | incident | Work Notes (u_work_notes) | Work Notes (u_work_notes) | Inactive | Inactive |
Configure a business rule
A business rule is a server-side script that is run to query a table or to display, insert, update, or delete a record.
To call OpsRamp APIs (details configured in the REST messages section) when an incident is created or updated:
- Define the conditions to trigger the rule
- Enter the script to invoke the API
To configure the business rule:
- Click All from the menu and search for System Definition and under that, click Business Rules.
- Click New to configure the business rule.
- Enter details in the Business Rule page and click Submit.
Name: Enter a name for the business rule
Example: OpsRamp Incident Integration RuleApplication: Default value - Global
Table: Select the table on which the business rule runs
Example: Incident to create an incidentActive: Select Active
Advanced: Select Active
When to run: Specify when to run the business rule.
- When: Default value - after. Select after and Insert. The option specifies that run the business rule after a record is inserted into the database.
- Order: Default value - 100. Order specifies the sequence in which the rule is executed.
- Insert: Select Active
- Update: Select Active
- Delete: Optional
- Query: Optional
- Filter Conditions:
- Created by is not System Administrator AND/OR
- Updated by is not System Administrator. The filter condition is designed to avoid looping. For example, when the OpsRamp API creates or updates an incident in ServiceNow, the script does not invoke the integration to OpsRamp.
- Actions: No configuration required
- Advanced:
- Condition: Optional
- Script: Enter the script
Click Submit.
- Create a custom field OpsRamp Incident ID in the ServiceNow incident table to save the OpsRamp incident ID. In the sample script, the custom field is u_opsramp_incident_id.
- If integration is at the OpsRamp client level, replace the variable OpsRampClientId
with the OpsRamp client ID in the sample script.
Example:var opsRampClientId = 'client_12345'
- If integration is at the OpsRamp partner level:
- Create a custom field OpsRamp Client ID in the ServiceNow Company table to save the OpsRamp client ID.
In the sample script, the custom field is u_opsramp_client_id.
- The custom field should take the value OpsRampClientId. Example:
var opsRampClientId _=_ current.company.u_opsramp_client_id
.
- The custom field should take the value OpsRampClientId. Example:
- Create a custom field OpsRamp Client ID in the ServiceNow Company table to save the OpsRamp client ID.
In the sample script, the custom field is u_opsramp_client_id.
If the activity has multiple rules running, rules are run priority order from low to high.
CMDB integration
For the ServiceNow CMDB integration with OpsRamp, the following shows how to do ServiceNow Integration with OpsRamp.
OpsRamp configuration
This section describes the configuration steps for ServiceNow CMDB integration.
- From All Clients, select a client.
- Go to Setup > Account.
- Select the Integrations and Apps tab.
- The Installed Integrations page, where all the installed applications are displayed. Note: If there are no installed applications, it will navigate to the Available Integrations and Apps page.
- Click + ADD on the Installed Integrations page. The Available Integrations and Apps page displays all the available applications along with the newly created application with the version.
Note: You can even search for the application using the search option available. Also yu can use the All Categories option to search. - Click ADD in the ServiceNow application and click Install.
- In the Inbound Configuration tab, enter:
- In the Authentication section, select authentication type as OAuth2.
Retain the Tenant ID, Key, and Secret information. This information is used in ServiceNow to create the OAuth provider. - Click Save.
- In the Authentication section, select authentication type as OAuth2.
- In the Outbound Configuration tab, enter:
- Prerequisite: The OAuth Client needs to be created in ServiceNow first.
- In the Integration Basic Configuration section, configure basic notification details to trigger events defined:
- Notification type: REST API
- Base URI: Base URL of ServiceNow instance
Example:https://demo2577.service-now.com
- Authentication type: OAuth2
- Grant Type: Password Credentials
- Access Token URL: Access Token URL of ServiceNow instance
Example:https://{subdomain}.com/oauth_token.do
- Key, Secret, Username, and** Password.
- Click Save.
- In the Integration Event section do the following steps to create an integration event:
- Click Add.
- Enter a name for the integration event.
- Select (resource/Any Resource/Create) for the field On.
- Select the Entity from the first drop-down list.
- Select the Entity Type from the second drop-down list.
- Select the Entity type event from the third drop-down list.
- Depending on the combination of selected Entity and Entity Type, the placeholders are updated in the right pane. Placeholders are the attributes that are used in the integration event API payload. Placeholders are categorized into Native, Additional, and Custom Attributes.
- Select Parent Configuration to assign the configured basic integration details.
- Select the web method as POST and enter the headers name and value. Go to Integration Event Payloads under Verify Integration to view the URL, headers, and payloads.
Prerequisite: Configure Import Sets - Enter the payload for the respective action and click Save.
- A custom field already configured as response payload attribute for a given integration is not available for configuration in any other integrations. Remove the existing mapping from the integration to make the custom field available for mapping in response payload of any other integration.
- To add more tokens to the payload, click the token in the placeholder list.
- To parse the properties returned in response for the configured API payload, select the property from the drop-down menu and enter the value.
Verify integration
To validate if the integration is successful, do the following:
- Select the event from the drop-down and select the payload type.
- Enter the payload and click Verify. A 200-OK success response is generated if the integration is successful.
Integration failures
In case of a failure in integration, a message is sent to the user. Select notification type Email, enter the email address, and click Save.
Integration event payloads
In event configuration, define web methods, payload data, and the endpoint URL to post the data to ServiceNow.
Refer to the integration event payload below to create CMDB in ServiceNow.
Fields | Values |
---|---|
Endpoint URL | {ServiceNow Base URI}/api/now/import/u_opsramp_ci Example: https://demo2577.service-now.com/api/now/import/u_opsramp_ci |
Headers |
|
Method | POST |
Example request
{
"u_caller_id": "6816f79cc0a8016401c5a33fdfdbe07441",
"u_opsramp_resource_id": "$defaultresource.uniqueId",
"u_ipaddress": "$defaultresource.ipAddress",
"u_macaddress": "$defaultresource.macAddress",
"u_dnsname": "$defaultresource.dnsName",
"u_hostname": "$defaultresource.name",
"u_make": "$defaultresource.make",
"u_model": "$defaultresource.model",
"u_resourcetype": "$defaultresource.resourceTag.name",
"u_systemuid": "$defaultresource.systemUID"
}
Example response
External Entity ID : $result[0].sys_id
Response from ServiceNow
{
"import_set": "ISET0010019",
"staging_table": "u_opsramp_ci",
"result": [{
"transform_map": "OpsRamp CI Trans Map",
"table": "cmdb_ci",
"display_name": "name",
"display_value": "Test_CI",
"record_link": "https://demo.service-now.com/api/now/table/cmdb_ci/7a528149db8e27808fad9b3c8a961978",
"status": "inserted",
"sys_id": "7a528149db8e27808fad9b3c8a961978"
}]
}
ServiceNow configuration
ServiceNow Kingston version supports OAuth2 authentication. Configuring OpsRamp API in ServiceNow involves the following:
- Configuring custom fields
- Configuring OAuth
- Configuring REST message
- Configuring import sets
- Configuring transform map
- Configuring business rule
Configure custom fields
Create the following custom fields:
- OpsRamp Resource ID Custom Field
- OpsRamp Client ID Custom Field
OpsRamp resource ID custom field
Create a custom field in ServiceNow cmdb_ci table to save OpsRamp resource ID in ServiceNow CI.
To create OpsRamp Resource ID Custom Field:
- Log into ServiceNow.
- Click All from the menu and search for System Definition and under that, click Dictionary.
- Select New to create a new field.
- Enter the required details:
-Table: Select
Configuration Item[cmdb_ci]
table- Application: Default value
- Type: Select
String
- Active: Active
- Column label: Enter a name to custom field
Example: OpsRamp Resource ID - Function Field: Default value
- Column name: Auto-generated when if Column label is provided
- Read only: Default value
- Max length: 64
- Mandatory: Default value
- Display: Default value
- Click Submit to save details.
- Configure the Form Layout to ensure that the OpsRamp Resource ID column is visible in the CI form.
OpsRamp Client ID Custom Field
Create a custom field (OpsRamp Client ID) in the ServiceNow Company table to save the OpsRamp Client ID as follows:
- Create OpsRamp Client ID if integration is performed at the OpsRamp partner level.
- Do not configure the OpsRamp Client ID if integration is performed at the client level.
To create the OpsRamp Client ID custom field:
- Click All from the menu and search for System Definition and under that, click Dictionary.
- Select New to create a field.
- Enter the required details:
- Table: Select
Company[core_company]
table - Application: Default value
- Type: Select String
- Active: Active
- Column label: Enter a name to custom field
Example: OpsRamp Client ID - Function Field: Default value
- Column name: Auto-generated when if Column label is provided
- Read only: Default value
- Max length: 64
- Mandatory: Default value
- Display: Default value
- Table: Select
- Click Submit to save details.
- Configure Form Layout to ensure that OpsRamp Client ID column is visible in the Company form.
After creating OpsRamp Client ID custom field, update OpsRamp client ID column for each company in ServiceNow.
To view the OpsRamp Client Id under Companies:
- Navigate to All > User Administration > Companies
Configure OAuth
To configure OAuth2 in ServiceNow:
- Create a user account
- Configure an OAuth Profile
- Create the OAuth client
- Create the OAuth provider
Create a user account
To create a user account:
- Click All from the menu and search for Organization and under that, click Users.
- Select New to create a user.
- Enter the user details and click Submit.
- In User profile, click the Roles > Edit.
- Select the roles required (rest_service and web_service_admin) and click Save.
Configure the OAuth profile
Validate if OAuth2 plugin is Active.
To do validation:
- Click All from the menu and search for System Definition and under that, click Plugins.
- Check the status of OAuth2 plugin.
Create OAuth Client
OAuth client is required to generate Client ID and Client Secret that are in turn required to configure ServiceNow authentication details in OpsRamp.
To create an OAuth client:
- Click All from the menu and search for System OAuth and under that, click Application Registry.
- Click New to create an Application Registry.
- Click Create an OAuth API endpoint for external clients.
- Enter the following details in the Application Registries page:
- Name: Enter a name
Example: SNOW OAuth2 Client - Application: Default value -Global
- Client ID: Auto-generated
- Accessible from: Default value - All application scopes
- Client Secret: Auto-generated
- Active: Select Active
- Refresh Token Lifespan: Default value - 8,640,000
- Access Token Lifespan: Default value - 1800
- Redirect URL: Optional
- Logo URL: Optional
- Comments: Enter comments about the client.
Example: SNOW OAuth2 client details required for OpsRamp to call SNOW APIs
- Name: Enter a name
- Click Submit.
Create OAuth Provider
An OAuth provider is required to configure the OpsRamp OAuth details to call APIs from ServiceNow. Before creating an OAuth Provider, do Inbound configuration in OpsRamp.
To configure OAuth provider:
Click All from the menu and search for System OAuth and under that, click Application Registry.
Click New from the Application Registry drop-down.
Click Connect to a third party OAuth provider.
Enter the details in Application Registries page:
- Name: Give a name
Example: OpsRamp OAuth2 Provider - Application: Default value - Global
- Client ID: Enter OpsRamp OAuth2 key
- Accessible from: Default value - All application scopes
- Client Secret: Provide OpsRamp OAuth2 secret
- Active: Select Active
- OAuth API Script: Optional
- Authorization URL: Optional
- Logo URL: Optional
- Token URL: Enter OpsRamp OAuth token URL -
https://{Your OpsRamp domain}/auth/oauth/token
.
Example:https://api.opsramp.com/auth/oauth/token
- Default Grant Type: Select Client Credentials
- Token Revocation URL: Optional
- Refresh Token Lifespan: Optional - 7200
- Redirect URL: Optional
- Comments: Enter SNOW OAuth2 client details required for OpsRamp to call SNOW APIs
- Name: Give a name
Click Submit to save the details.
Configure a REST message
REST messages are used to configure OpsRamp API details. REST messages can be invoked from a business rule script depending on certain criteria.
Do the following steps to configure a REST message:
- Configure a REST message
- Configure a REST message using the HTTP method:
- Create a resource using the HTTP method
- Update a resource using the HTTP method
Procedure to configure a REST message
Log into ServiceNow.
Click All from the menu and search for System OAuth and under that, click Application Registry. Click System Web Services on the left pane and click REST Message.
Select New to create a REST message.
Enter the details for the REST message.
- Name: Enter a name for the REST message. This name is required in the business rule script (Example: OpsRamp CI REST)
- Application: Default value - Global
- Accessible from: Default value - This application scope only
- Description: Enter description about REST message
Example: Rest message to call OpsRamp resource API - Endpoint:
https://{your OpsRamp domain}
Example:https://api.opsramp.com
- Authentication:
- Authentication type: Select OAuth 2.0
- OAuth profile: Search profiles and select OAuth provider profile created in OAuth section
Example: OpsRamp OAuth2 Provider default profile
- HTTP Request: No configurations required
To learn more about APIs, see Getting Started.
Click Submit to save the details.
Configure a REST message using the HTTP Method
After creating the REST message, use the following HTTP methods to configure the OpsRamp resource API details:
- Create the resource using the HTTP method
- Update a resource using the HTTP method
Step 1: Create the resource using the HTTP method
- Click New on the HTTP method page.
- Enter details in the HTTP Method page.
- REST Message: Automatically populates OpsRamp CI REST
- Application: Default value - Global
- Name: Provide a name (Example: Create)
- HTTP Method: Select
POST
- Endpoint:
https://{your OpsRamp domain}/api/v2/tenants/${tenantId}/resources
Example:https://api.opsramp.com/api/v2/tenants/${tenantId}/resources
- Authentication: Authentication type - Select Inherit from Parent. Because authentication details are pre-configured in the REST message, the details are automatically inherited.
- Click Submit.
The placeholder in Endpoint is replaced in the business rule script.
HTTP Request
Fields | Values |
---|---|
HTTPS Headers | Create Content-Type header
|
HTTP Query Parameters | Provide OpsRamp create resource payload |
Example payload
{
"dnsName": "${dsnNameToken}",
"hostName": "${hostNameToken}",
"resourceType": "${resourceTypeToken}",
"os": "${osToken}",
"serialNumber": "${serialNumberToken}",
"make": "${makeToken}",
"model": "${modelToken}",
"resourceNetworkInterface": [{
"macAddress": "${macAddressToken}",
"ipAddress": "${ipAddressToken}"
}]
}
Step 2: Update a resource using the HTTP method
To configure OpsRamp update resource API:
Click New on the HTTP method page.
Enter details:
- REST Message: Automatically populates OpsRamp CI REST
- Application: Default value - Global
- Name: Provide a name
Example: Update - HTTP Method: Select
POST
- Endpoint:
https://{your OpsRamp domain}/api/v2/tenants/${tenantId}/resources/${resourceId}
Example:https://api.opsramp.com/api/v2/tenants/${tenantId}/resources/${resourceId}
- Authentication: Authentication type - Select Inherit from Parent. As authentication details are configured already in REST message, the details are inherited.
Click Submit.
The placeholder in Endpoint is replaced in the business rule script.
Example HTTP Request
Fields | Values |
---|---|
HTTPS Headers | Create Content-Type header
|
HTTP Query Parameters | Provide OpsRamp update resource payload |
Example payload
{
"dnsName": "${dsnNameToken}",
"hostName": "${hostNameToken}",
"resourceType": "${resourceTypeToken}",
"os": "${osToken}",
"serialNumber": "${serialNumberToken}",
"make": "${makeToken}",
"model": "${modelToken}",
"resourceNetworkInterface": [{
"macAddress": "${macAddressToken}",
"ipAddress": "${ipAddressToken}"
}]
}
Configure import sets
Import sets allows data to be imported from various data sources and map the data into ServiceNow tables. This can be achieved by creating a staging table to save OpsRamp Resource columns.
To configure import sets, do the following:
- Create a table
- Create table columns
Create a table
To create a table:
- Click All from the menu and search for System Definition and under that, click Tables.
- Select New to create a table.
- Fill required details:
- Label: Enter a label to the table (Example: OpsRamp CI)
- Application: Default value
- Name: Auto-generated when if a Label value is provided
- Create module: Default value
- Create mobile module: Default value
- Add module to menu: Default value
- Extends table: Select
Import Set Row
- Click Submit to save table.
Create table columns
To create table columns:
- Select the created table name
OpsRamp CI[u_opsramp_ci]
from the Table drop-down. - On the Columns tab, click New to create a table column.
Column Label | Table | Application | Type | Active | Function Field | Column name | Read only | Max Length | Mandatory | Display |
---|---|---|---|---|---|---|---|---|---|---|
Host Name | OpsRamp CI[u_opsramp_ci] | Default Value | String | Active | Default Value | Auto-generated value | Inactive | 255 | Active | Inactive |
IP Address | OpsRamp CI[u_opsramp_ci] | Default Value | String | Active | Default Value | Auto-generated value | Inactive | 255 | Inactive | Inactive |
MAC Address | OpsRamp CI[u_opsramp_ci] | Default Value | String | Active | Default Value | Auto-generated value | Inactive | 255 | Inactive | Inactive |
DNS Name | OpsRamp CI[u_opsramp_ci] | Default Value | String | Active | Default Value | Auto-generated value | Inactive | 255 | Inactive | Inactive |
Make | OpsRamp CI[u_opsramp_ci] | Default Value | String | Active | Default Value | Auto-generated value | Inactive | 255 | Inactive | Inactive |
Model | OpsRamp CI[u_opsramp_ci] | Default Value | String | Active | Default Value | Auto-generated value | Inactive | 255 | Inactive | Inactive |
OpsRamp Resource ID | OpsRamp CI[u_opsramp_ci] | Default Value | String | Active | Default Value | Auto-generated value | Inactive | 64 | Active | Inactive |
System UID | OpsRamp CI[u_opsramp_ci] | Default Value | String | Active | Default Value | Auto-generated value | Inactive | 255 | Inactive | Inactive |
Resource Type | OpsRamp CI[u_opsramp_ci] | Default Value | String | Active | Default Value | Auto-generated value | Inactive | 255 | Active | Inactive |
This table only shows required fields. Add more columns if needed.
Here is a sample output table:
Configure the transform map
Configuring the transform map involves the following:
- Create a transform map.
- Configure field maps.
Create a transform map
A transform map is a set of field maps that determines the relationships between fields in an import set and fields in an existing ServiceNow table. These relationship needs to be defined between the staging table and the CI table. The staging table is created using import sets.
To create a transform map:
- Click All from the menu and search for System Import Sets and under that, click Transform Maps.
- Select New to create a new Transform Map.
- Enter the required details:
- Name: Enter a name to transform map
Example: OpsRamp CI Trans Map - Created: Default value
- Source table: Select staging table created
Example:OpsRamp CI[u_opsramp_ci]
- Target table: Select
Configuration Item[cmdb_ci]
- Active: Active
- Order: Default value
- Run business rules: Active
- Run script: Active and place
CI_Trans_map_script.js
in the script field - Enforce required fields: Select
No
- Copy empty fields: Default value
- Name: Enter a name to transform map
- Click Submit to save the details.
The sample script is configured for Linux and Load Balancer. A script can be customized for other resource type mappings.
Configure field maps
After creating a transform pap, configure field maps for each column in the staging table
u_opsramp_ci **with the** cmdb_ci
table.
To configure field maps:
- Select the transform map created (
OpsRamp CI Trans Map
) from the Map drop-down. - Click New on the Field Maps page.
- Create map for the following columns:
Map | Source Table | Target Table | Source Field | Target Field | Coalesce | Use Source Script |
---|---|---|---|---|---|---|
OpsRamp CI Trans Map | OpsRamp CI[u_opsramp_ci] | Configuration Item[cmdb_ci] | Host Name | Name | Inactive | Default |
OpsRamp CI Trans Map | OpsRamp CI[u_opsramp_ci] | Configuration Item[cmdb_ci] | IP Address | IP Address | Inactive | Default |
OpsRamp CI Trans Map | OpsRamp CI[u_opsramp_ci] | Configuration Item[cmdb_ci] | MAC Address | MAC Address | Inactive | Default |
OpsRamp CI Trans Map | OpsRamp CI[u_opsramp_ci] | Configuration Item[cmdb_ci] | DNS Name | DNS Domain | Inactive | Default |
OpsRamp CI Trans Map | OpsRamp CI[u_opsramp_ci] | Configuration Item[cmdb_ci] | Make | Make | Inactive | Default |
OpsRamp CI Trans Map | OpsRamp CI[u_opsramp_ci] | Configuration Item[cmdb_ci] | Model | Model | Inactive | Default |
OpsRamp CI Trans Map | OpsRamp CI[u_opsramp_ci] | Configuration Item[cmdb_ci] | OpsRamp Resource ID | OpsRamp Resource ID | Active | Default |
OpsRamp CI Trans Map | OpsRamp CI[u_opsramp_ci] | Configuration Item[cmdb_ci] | Resource Type | Class | Inactive | Default |
Configure business rules
A business rule is a server-side script that is run to display, insert, update, or delete a record or to query a table. To call OpsRamp APIs when a configuration item is created or updated, do the following:
- Define the conditions to trigger the rule.
- Enter the script to invoke the API.
The details on configuring is in the REST messages section.
To configure a business rule:
- Click All from the menu and search for System Definition and under that, click Business Rules.
- Select New to configure the business rule.
- Enter details in the Business Rule page:
- Name: Provide a name for the business rule
Example: OpsRamp CMDB Integration Rule - Application: Default value – Global
- Table: Select the table on which the business rule runs from the list.
Example: CMDB CI Actions [statemgmt_cmdb_actions] - Active: Select Active
- Advanced: Select Active
- When to run: Specify when to run the business rule.
This filter condition is provided to avoid looping by invoking the integration back to OpsRamp when the OpsRamp API creates or updates CI in ServiceNow. The System Administrator is the user created during authentication.- When: Default value – after. Select after and Insert. The option specifies that run the business rule after a record is inserted into the database.
- Order: Default value – 100. The order specifies the sequence in which the rule is executed.
- Insert: Select Active
- Update: Select Active
- Delete: Optional
- Query: Optional
- Filter Conditions:
- Created by is not System Administrator AND/OR
- Updated by is not System Administrator
- Actions: No configuration required
- Advanced:
- Condition: Optional
- Script: Enter the script here.
- Name: Provide a name for the business rule
- Click Submit.
The following are usage notes:
- Create custom field OpsRamp Resource ID in ServiceNow cmdb_ci table to save OpsRamp resource ID.
In sample script field for this is
u_opsramp_resource_id
- If integration is at OpsRamp Client level, replace variable OpsRampClientId
with OpsRamp client ID in sample script. Example:
var opsRampClientId = ‘client_12345’
- If integration is at an OpsRamp partner level:
- Create a custom field OpsRamp Client ID in the ServiceNow company table to save the OpsRamp client ID.
In the sample script, the custom field is
u_opsramp_client_id
.- The custom field should take the value OpsRampClientId. Example:
var opsRampClientId_ = _current.company.u_opsramp_client_id
.
- The custom field should take the value OpsRampClientId. Example:
- Create a custom field OpsRamp Client ID in the ServiceNow company table to save the OpsRamp client ID.
In the sample script, the custom field is
If the activity has multiple rules running, rules are run priority order from low to high.
Configuration items can be viewed in Service (or vice versa).
Monitoring of Integration
Assign a template from the Monitoring of Integration tab, if you want to monitor integration failures. See monitoring integration failures for more information.
Audit Logs
View logs from the Audit Logs tab. You can view if the event was successful or not.