Insight · Topic 2 of 4

Querying the CMDB and Building Reports

Query the CMDB for the CIS-DF exam: natural language query, CMDB Query Builder relationships, full result sets, CMDB 360 saved queries and reports.

  • 5 min
In a nutshell
  • NLQ turns a sentence into a query that can open on the Query Builder canvas.
  • The first node on the canvas is the starting node; a non-CMDB table cannot be it.
  • Every node on the path must match for a row to appear.

What it is

A list filter cannot answer "which Linux servers support this application service", because the answer spans class tables and relationships. ServiceNow gives you three ways to ask.

Natural language query (NLQ), also called Intelligent Search for CMDB, turns a plain sentence into a query. The CMDB Query Builder draws a query across classes, relationships and some non-CMDB tables. CMDB 360 saved queries ask what each discovery source reported.

Plain sentenceNLQQuery on the canvasCMDB Query Buildernodes, connections, filtersSaved queryscheduleReport

How it works

Natural language query

You type a sentence such as "show me all servers located in San Diego" into the search box in CMDB Workspace, and the platform converts it into a valid query.

When the query spans more than one table, you can open it in the CMDB Query Builder, fully built on the canvas. The feature is controlled by the system property glide.cmdb.query.nlq.activated, which is true by default.

NLQ suits users who do not know class names; refine and save the query in the Query Builder when it must be precise or repeatable.

CMDB Query Builder basics

Open it from All > Configuration > CMDB Query Builder. There are two query types:

Query typeWhat it searchesRelationship matching
CMDB queryCI classes, their relationships and references, plus optional non-CMDB tablesDirect relationships, or up to the second level if you choose
Service Mapping queryApplication service maps that contain a pattern you defineDirect and multi-level indirect relationships within the map

Dragging a saved Service Mapping query into a CMDB query builds a combination query; Does Not Belong To Service inverts it.

The first class dragged to the canvas becomes the fixed starting node. Non-CMDB tables such as Incident or Asset can be added, but never as the starting node.

Building complex relationships

Connect two nodes and the Connection Properties panel appears. These settings decide which rows qualify:

SettingUse it when
Relationship directionYou must say which node is the parent
First level relationshipsThe CIs are directly related
Up to 2nd level relationshipsThe CIs may be connected through one CI in between
Add Relationship TypesOnly specific types, such as Runs on, should match
No RelationshipsYou want CIs that lack a relationship to the other class
Add a Related Item or CI reference columnThe link is a reference field rather than a relationship

Connect one node to two others to toggle And or Or. Add filters per node and pick columns under Properties.

A CMDB query returns a row only when every node on the path matches. If results look too few, check filters, direction and level first.

Getting the full set of results

Run shows the first 100 results. Load More Results adds 100 more; Load All Results loads the rest, up to glide.cmdb.query.max_results_limit (10,000 by default).

For repeatable output, save the query and create a schedule, which runs it later or on a recurring basis and can email the results.

Reports from saved queries

A dynamic report shows the latest results of a saved query and updates on every scheduled run. To create one, the query must be saved, have a schedule and have a complete result set from a run.

Creating it needs cmdb_query_builder (or cmdb_query_builder_read) plus report_user. If you change the query definition, the report falls out of sync and must be recreated.

CMDB 360 saved queries

With CMDB 360 enabled, CMDB Workspace has a CMDB 360 page in its menu bar (in Service Graph Workspace it sits under Insights). Its Saved queries card shows up to 20 of your queries, of three types:

CMDB 360 query typeAnswers
Get RecordsWhich CIs did these discovery sources report?
Find GapWhich sources report a CI and which do not?
Compare Attribute ValuesWhere do two or more sources, or the CMDB, disagree on a value?

Scheduling a CMDB 360 query lets you build a report on it. The page needs the sn_cmdb_user role.

How the exam asks about this

  • "A manager with no table knowledge wants a quick list of servers in one city." Use natural language query in CMDB Workspace.
  • "A query finds databases related to servers, but databases linked through a cluster in between are missing." Set the connection to Up to 2nd level relationships.
  • "Operations wants a weekly report of CIs where two discovery sources report different RAM values." A scheduled CMDB 360 Compare Attribute Values query, then a report.

What to remember for the exam

  • NLQ turns a sentence into a query that can open on the Query Builder canvas.
  • The first node on the canvas is the starting node; a non-CMDB table cannot be it.
  • Every node on the path must match for a row to appear.
  • Run shows 100 rows; Load All Results is capped by glide.cmdb.query.max_results_limit.
  • A Query Builder report needs a saved, scheduled query with complete results.
  • CMDB 360 queries are Get Records, Find Gap and Compare Attribute Values.
Watch out

Export takes only visible rows, so exporting straight after Run gives at most 100. Load all results first, or schedule and report.

Common mistakes

Blaming the data for a short result. A missing row often means a node filter or the relationship level excluded it.

Using a CMDB query for source conflicts. A CMDB query reads reconciled CI values. Per-source questions belong to CMDB 360 queries.

Editing a query behind a live report. Changing the query definition breaks the link to its dynamic report, so create a new one.

Check yourself

  • What happens when a natural language query spans more than one table?

    The query can be opened in the CMDB Query Builder, where it appears fully built on the canvas for refining and saving.

  • What must be true before you can create a dynamic report from a CMDB Query Builder query?

    The query must be saved, have a schedule and have a complete set of results from a run.

  • Which CMDB 360 query type shows the discovery sources that do not report a CI?

    Find Gap, which compares the sources that report a CI with those that do not.

Topic 2 of 4 in Insight

Test yourself on Insight

The full ServiceNow CIS-DF question bank has 769 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by ServiceNow. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.