turbot/servicenow
steampipe plugin install servicenow

ServiceNow + Steampipe

ServiceNow is a cloud-based platform that provides digital workflows to help businesses improve their operational efficiency and enhance customer and employee experiences.

Steampipe is an open-source zero-ETL engine to instantly query cloud APIs using SQL.

For example:

select
number,
short_description,
category,
priority
from
servicenow_incident
where
state = 1;
+------------+---------------------------------------+----------+----------+
| number | short_description | category | priority |
+------------+---------------------------------------+----------+----------+
| INC0000039 | Trouble getting to Oregon mail server | network | 5 |
| INC0000046 | Can't access SFA software | software | 3 |
| INC0009001 | Unable to post content on a Wiki page | inquiry | 3 |
| INC0000057 | Performance problems with wifi | inquiry | 5 |
| INC0009005 | Email server is down. | software | 1 |
| INC0007002 | Need access to the common drive. | inquiry | 4 |
+------------+---------------------------------------+----------+----------+

Documentation

Get started

Install

Download and install the latest ServiceNow plugin:

steampipe plugin install servicenow

Credentials

ItemDescription
CredentialsServiceNow API requires an instance URL, username, and password for all requests.
RadiusEach connection represents a single ServiceNow Installation.
Resolution1. Credentials explicitly set in a steampipe config file (~/.steampipe/config/servicenow.spc)
2. Credentials specified in environment variables, e.g., SERVICENOW_PASSWORD.

Configuration

Installing the latest servicenow plugin will create a config file (~/.steampipe/config/servicenow.spc) with a single connection named servicenow:

connection "servicenow" {
plugin = "servicenow"
# `instance_url` (required) - Your ServiceNow instance URL.
# instance_url = "https://<your_servicenow_instance>.service-now.com"
# `username` (required) - Your ServiceNow username.
# username = "john.hill"
# `password` (required) - Your ServiceNow password.
# password = "j0t3-$j@H3"
# Optionally, to use OAuth2 authentication mode, you'll need to have the `client_id` and `client_secret` of
# a registered application in ServiceNow. You can register an application by going to
# `All > System oAuth > Application Registry` and creating a new OAuth API endpoint for external clients.
# `client_id` (optional) - ServiceNow login application client ID.
# client_id = "9148ce34f5252110392c96f819dbd422"
# `client_secret` (optional) - ServiceNow login application client secret.
# client_secret = "Ly#2auTd"
# `objects` (optional) - Additional ServiceNow tables you want to query.
# objects = ["cmdb_model", "cmn_location"]
}

Credentials from Environment Variables

The ServiceNow plugin will use environment variables to obtain credentials:

Basic Auth

export SERVICENOW_INSTANCE_URL=https://<your_servicenow_instance>.service-now.com
export SERVICENOW_USERNAME=john.hill
export SERVICENOW_PASSWORD=j0t3-$j@H3

OAuth2 - password mode

export SERVICENOW_INSTANCE_URL=https://<your_servicenow_instance>.service-now.com
export SERVICENOW_USERNAME=john.hill
export SERVICENOW_PASSWORD=j0t3-$j@H3
export SERVICENOW_CLIENT_ID=9148ce34f5252110392c96f819dbd422
export SERVICENOW_CLIENT_SECRET=Ly#2auTd

Postgres FDW

This plugin is available as a native Postgres FDW. Unlike Steampipe CLI, which ships with an embedded Postgres server instance, the Postgres FDW can be installed in any supported Postgres database version.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_postgres_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/postgres.sh)" -- servicenow

The installer will prompt you for the plugin name and version, download and install the appropriate files for your OS, system architecture, and Postgres version.

To configure the Postgres FDW, you will create an extension, foreign server, and schema and import the foreign schema.

CREATE EXTENSION IF NOT EXISTS steampipe_postgres_servicenow;
CREATE SERVER steampipe_servicenow FOREIGN DATA WRAPPER steampipe_postgres_servicenow OPTIONS (config '<your_config>');
CREATE SCHEMA servicenow;
IMPORT FOREIGN SCHEMA servicenow FROM SERVER steampipe_servicenow INTO servicenow;

SQLite Extension

This plugin is available as a SQLite Extension, making the tables available as SQLite virtual tables.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_sqlite_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/sqlite.sh)" -- servicenow

The installer will prompt you for the plugin name, version, and destination directory. It will then determine the OS and system architecture, and it will download and install the appropriate package.

To configure the SQLite extension, load the extension module and then run the steampipe_configure_servicenow function to configure it with plugin-specific options.

$ sqlite3
sqlite> .load ./steampipe_sqlite_extension_servicenow.so
sqlite> select steampipe_configure_servicenow('<your_config>');

Export

This plugin is available as a standalone Export CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- servicenow

You can pass the configuration to the command with the --config argument:

steampipe_export_servicenow --config '<your_config>' <table_name>