Grafana Cloud Enterprise
Last reviewed: March 8, 2026

ServiceNow query editor

The ServiceNow query editor lets you build queries that retrieve records or aggregate statistics from your ServiceNow tables. Use Table queries to display individual records like incidents and change requests, or Stats queries to calculate metrics such as incident counts, average resolution times, and category breakdowns.

Before you begin

Key concepts

The following terms are used throughout this document:

TermDescription
Table APIServiceNow REST API that returns individual records from a table. Used by Table queries.
Aggregate APIServiceNow REST API that returns aggregated statistics (count, sum, average, etc.) for table data. Used by Stats queries.
Display valueA human-friendly label for a field value. For example, a severity of 1 displays as 1 - High when display values are enabled.
Field referenceA field that points to a record in another ServiceNow table. You can expand references to access fields from the related table using dot notation.

Query types

The ServiceNow query editor supports two query types, selectable from the Query drop-down:

  • Table: Returns individual records from a ServiceNow table. Use this for displaying data in table panels, stat panels, or any visualization that works with raw records.
  • Stats: Returns aggregated statistics about table data using the Aggregate API. Use this for metric-based visualizations like graphs, bar charts, and gauges.

Table query

A Table query retrieves records from a ServiceNow table with options to select fields, filter results, sort, and limit the number of rows returned.

Table

Select a ServiceNow table from the Table drop-down. A predefined set of common tables is listed by default, but you can type a custom table name to query any table the user has access to.

Show Fields

Select one or more fields to display using the Show Fields selector. Fields are returned in the order you specify. If Use Sys Tables? is enabled in the data source configuration, the drop-down is populated with available fields from the ServiceNow dictionary.

Display value

The Display Value setting controls whether the query returns raw values or human-friendly labels. Select one of the following options:

OptionDescription
AllDisplays human-friendly labels for choice fields and renders integer fields as numbers. This is the default and recommended option.
TrueDisplays human-friendly labels for choice fields and renders integer fields as formatted strings.
FalseDisplays raw values for all fields. Choice fields like severity and state display as integer IDs (for example, 1 instead of 1 - High). This option may provide better query performance.

Note

According to the ServiceNow API documentation, All and True modes may be slower than False mode.

Time field

The Time Field setting determines how the query interacts with your dashboard’s time range.

By default, the time field toggle is disabled and the query uses Ignore Time mode. In this mode, results aren’t filtered by the dashboard time range, and filters control which data is displayed.

When you enable the toggle, select a date or time field (for example, opened_at). Only records with values in that field that fall within the dashboard’s time range are returned.

Sort by

Use the Sort By setting to order results by one or more fields. For each sort entry, select a field and choose asc (ascending) or desc (descending) order.

Limit

Set a maximum number of rows to return. The default limit is 25. Increase this value to retrieve more records, but be aware that large result sets may affect performance.

Stats query

A Stats query retrieves aggregated statistics from a ServiceNow table using the Aggregate API.

Show Field

Select one or more fields and the aggregation(s) to apply to each field. The following aggregations are available:

AggregationDescription
avgAverage value of the field.
minMinimum value of the field.
maxMaximum value of the field.
sumSum of all values in the field.
countNumber of records matching the query.

You can apply multiple aggregations to a single field and add multiple fields to a single query.

Group by

Use the Group By setting to split aggregated results by one or more fields. For example, grouping by priority returns separate aggregated values for each priority level.

Group by results include a tag with the group field name and its values, which you can use with the Labels to Fields transformation to create separate columns.

Filters

Stats queries support the same filter options as Table queries. Refer to the Filters section.

Filters

Both Table and Stats queries support filters to narrow down results. Add filters using the Filters section of the query editor.

Filter structure

Each filter consists of:

  • Field: The ServiceNow table field to filter on.
  • Operator: The comparison operator.
  • Value: The value to compare against (some operators don’t require a value).
  • Conjunction: How this filter combines with the next filter (AND, OR, or NQ).

Conjunctions

ConjunctionDescription
ANDBoth the current filter and the next filter must be true.
OREither the current filter or the next filter must be true.
NQStarts a new query group. Use NQ (New Query) to create independent filter groups that are evaluated separately.

String operators

OperatorDescription
Starts WithField value starts with the specified text.
Ends WithField value ends with the specified text.
LikeField value contains the specified text.
Not LikeField value doesn’t contain the specified text.
EqualsField value exactly matches the specified text.
Not EqualsField value doesn’t match the specified text.
Is EmptyField has no value (null).
Is Not EmptyField has a value (not null).
Is one ofField value matches one of the specified values.
Is not one ofField value doesn’t match any of the specified values.
Is anythingMatches any value (no filtering).
Is empty stringField value is an empty string.

Date operators

OperatorDescription
TodayField value falls within today.
Not TodayField value doesn’t fall within today.
BeforeField value is before the specified date.
At or BeforeField value is on or before the specified date.
AfterField value is after the specified date.
At or AfterField value is on or after the specified date.
Relative (on or after)Field value is on or after a relative time period.
Relative (on or before)Field value is on or before a relative time period.
Relative (after)Field value is after a relative time period.
Relative (before)Field value is before a relative time period.
Relative (on)Field value falls on a relative time period.

Number operators

OperatorDescription
=Field value equals the specified number.
!=Field value doesn’t equal the specified number.
EmptyField has no value.
Not EmptyField has a value.
>Field value is greater than the specified number.
<Field value is less than the specified number.
<=Field value is less than or equal to the specified number.
>=Field value is greater than or equal to the specified number.
Is one ofField value matches one of the specified numbers.
Is not one ofField value doesn’t match any of the specified numbers.

Boolean operators

OperatorDescription
EqualsField value equals True or False.
Not EqualsField value doesn’t equal the specified boolean.
Is emptyField has no value.
Is not emptyField has a value.
Is anythingMatches any value.

Filter value types

The input for filter values depends on the field type:

  • Boolean fields: Display a True/False selector.
  • Text fields: Display a free-text input.
  • Date fields: Display a date picker when a date value is required.
  • Choice fields: Display a drop-down with available choices (when Use Sys Tables? is enabled).
  • No-value operators: Operators like Is anything, Today, Not Today, Is Empty, Is Not Empty, and Is empty string don’t display an additional input.

Field references

Fields that reference other ServiceNow tables can be expanded to access fields from the related table. In the field selector, reference fields display a collapse indicator. Click to expand and view the available sub-fields.

To use a field from a referenced table, select it using dot notation (for example, caller_id.name to get the caller’s name from the sys_user table).

Note

Field references expand to one level deep only. If a referenced table contains its own reference fields, those second-level references can’t be expanded further.

Annotations

The ServiceNow data source supports annotations using the standard query editor. For examples and a step-by-step guide, refer to Annotate dashboards with ServiceNow events.

Transformations

You can apply transformations to ServiceNow query results to reshape data for your visualizations.

The Labels to fields transformation is particularly useful with Stats queries that use Group By. It converts group-by label values into separate table columns.

Next steps