Skip to main content

ServiceNow Event Destinations

The SERVICE_NOW adapter creates one record in a ServiceNow table for each event, with the Table API. The default table is incident.

For the events that a destination receives, retries, deliveries, and pause, refer to Event Destinations.

Settings​

ObjectFieldValue
configinstanceThe name of your instance: acme for https://acme.service-now.com. Required.
configtableThe table that gets a record for each event. The default is incident. The table must have a correlation_id field, as incident and the other tables that extend task have.
configfieldsField names and values that each record gets, such as assignment_group or urgency. Each value is a string.
authusernameA ServiceNow user that can read and create records in the table. It cannot contain :. Required.
authpasswordThe password of that user. Required.

Massdriver sends requests only to https://<instance>.service-now.com. An instance on a custom domain is not supported.

ServiceNow destinations do not have a signing secret.

Make a ServiceNow user​

  1. In ServiceNow, create a user for Massdriver, such as massdriver. Select Web service access only.
  2. Give the user a role that can read and create records in the table. For incident, the itil role is enough.
  3. Set a password for the user.

Add the destination​

In the Massdriver UI:

  1. Go to Organization Settings → Event destinations, and click New destination.
  2. Select ServiceNow.
  3. Enter a Name and the Instance. Optional: enter the Table and the Fields.
  4. Under Credentials, enter the User name and Password.
  5. Choose the Events. Refer to Choose events.
  6. Click Create destination.

With the API, use createEventDestination with adapter: SERVICE_NOW. Pass auth as a variable:

mutation CreateEventDestination($auth: Map) {
createEventDestination(
organizationId: "my-org"
input: {
name: "Failed production deployments"
adapter: SERVICE_NOW
config: "{\"instance\": \"acme\", \"fields\": {\"assignment_group\": \"Platform\", \"urgency\": \"2\"}}"
auth: $auth
eventTypes: ["deployment.failed"]
attributes: "{\"md-environment\": \"prod\"}"
}
) {
result { id }
successful
messages { field message }
}
}
{
"auth": "{\"username\": \"massdriver\", \"password\": \"...\"}"
}

Use cases​

Each use case is one destination. To send different events with different fields, such as a higher urgency for production, make one destination for each set of fields. For the attribute keys, refer to Attribute keys.

Incidents for failed production deployments​

SettingValue
Eventsdeployment.failed, deployment.aborted
Attributes{"md-environment": "prod"}. To limit it to one project, add "md-project": "api". To limit it to one bundle, add "md-repo": "aws-aurora".
Condition.data.metadata.deployment_action != "PLAN", to skip failed plans
Tableincident
Fields{"assignment_group": "Platform", "urgency": "2", "impact": "2", "category": "software"}

Incidents when a production alarm fires​

SettingValue
Eventsalarm_state.created
Attributes{"md-environment": "prod"}. To limit it to databases, add "md-component": "database". To limit it to one instance, use "md-instance": "api-prod-database".
Condition.data.entity.status == "ALARM", to skip the change back to OK
Tableincident
Fields{"assignment_group": "Platform", "urgency": "1", "impact": "1"}

Massdriver opens a new incident each time an alarm changes to ALARM. It does not close the incident when the alarm changes back to OK.

Security review when a secret leaves Massdriver​

SettingValue
Eventsresource.exported
Attributes(empty). To limit it to production, use {"md-environment": "prod"}.
Condition.data.metadata.contains_secrets == true. To limit it to IAM roles, add and (.data.attributes["md-resource-type"] // "" \| startswith("aws-iam-role@")).
Tableincident, or a security table that extends task
Fields{"assignment_group": "Security", "category": "security"}

Access changes for an audit trail​

SettingValue
Eventsaccess_token.created, access_token.revoked, service_account.created, service_account.deleted, group_membership.added, group_membership.removed
Attributes(empty). These events have no attributes, so a destination with Attributes never receives them.
Condition(empty)
TableA table that extends task and that your security team reviews
Fields{"assignment_group": "Security"}

A record of each production change​

SettingValue
Eventsdeployment.completed
Attributes{"md-environment": "prod"}
Condition.data.metadata.deployment_action != "PLAN". To record only removals, use .data.metadata.deployment_action == "DECOMMISSION".
Tablechange_request, or another table that extends task
FieldsThe fields that your change process requires, such as category and assignment_group

Use the preview on the destination to see the recent events that a use case selects before you save it.

Limits​

  • Massdriver only creates records. It does not update or close a record, for example when an alarm changes back to OK.
  • The values in config.fields are the same for every record of a destination. To use different values, make more than one destination.
  • Massdriver does not set cmdb_ci from the event. You can set one fixed cmdb_ci in config.fields.
  • The table must have a correlation_id field.
  • Massdriver uses basic authentication, and sends only to https://<instance>.service-now.com.

The record​

FieldValue
short_descriptionA headline that tells what happened, such as Deploy of api-prod-database failed. It is the same headline as in a Slack message, without the emoji. At most 160 characters.
descriptionThe message of the deployment or of the alarm, when the event has one. Then details such as the bundle version and the person who deployed. Then the time, the event type and id, and the subject. Last, a link to the page of the entity's instance, environment, or project in Massdriver, when the event is about a project.
correlation_idThe event id.
correlation_displayMassdriver

The record also gets each field in config.fields. If config.fields has short_description, description, correlation_id, or correlation_display, Massdriver uses its own value.

Before Massdriver creates a record, it looks for a record in the table with the event id as correlation_id. If one exists, Massdriver does not create a second record. Thus a retry does not make a duplicate record. If the user cannot read the table, ServiceNow returns no records, and a retry can make a duplicate.

Responses​

ResultWhat Massdriver does
200 or 201The event is sent.
408, 429, or 5xx, no response in 10 seconds, or a connection that cannot be madeMassdriver retries the event.
Any other status, such as 401, 403, or 404The event becomes a failed event at once.
A response that is not a Table API result, such as the page of a hibernating instanceThe event becomes a failed event at once.

The destination's lastError field shows the status, for example HTTP 401. Refer to Failures and retries.

ErrorWhat to do
HTTP 401Make sure that the user name and password are correct, and update the destination's credentials.
HTTP 403Give the user a role that can read and create records in the table.
HTTP 404Make sure that the instance name and the table are correct.

After you repair the problem, send the failed events again.