Querying the CMDB
Summarize
Summary of Querying the CMDB
The CMDB Query Builder in ServiceNow enables users to construct complex queries across various CMDB classes and non-CMDB tables. Users can easily create queries by dragging CI classes, defining relationships, and specifying properties. This tool facilitates the grouping of Configuration Items (CIs) and allows for collective actions through scriptable APIs.
Show less
Key Features
- Query Types: There are two primary query types: CMDB Query and Service Mapping Query, which can be used independently or combined.
- Intelligent Search: Integrated into the Query Builder, it allows for natural language queries to simplify the querying process.
- Relationship Properties: Users can configure connection properties such as relationship type, direction, and level to refine their queries.
- Domain Separation: Supports logical separation of data and processes for better data management and access control.
- Query Management: Users can save, delete, schedule, export, and import queries efficiently.
Key Outcomes
By utilizing the CMDB Query Builder, ServiceNow customers can:
- Efficiently query and manage CIs and their relationships, leading to better insights into infrastructure and services.
- Leverage natural language processing for easier query creation and reduce the complexity of query management.
- Perform targeted analysis on application services and their underlying infrastructure, aiding in cost evaluation and incident management.
The CMDB Query Builder allows you to easily build complex infrastructure and service queries, that span multiple CMDB classes, non-CMDB tables, and that involve many CIs that are connected by different relationships.
The CMDB Query Builder provides a canvas into which you drag the CI classes that you want to include in a query. Then you add relationships, AND/OR operators between the CI classes, and define the relationship properties to query for. You can use saved queries to populate a CMDB group with CIs, and then use scriptable APIs to retrieve the CI list and apply actions collectively to all the CIs in the group.
There are two query types: CMDB Query and a Service Mapping query, which you can use separately or in combination to create queries such as:
- All hardware in my service offering that has Windows installed.
- All CIs of a certain type in an application service. For example, all Apaches/Web Servers/Linux servers per service.
- All virtual servers and the physical servers that host them.
- All servers that are not mapped to any application service.
- All application services and their associated servers and the cost of each server. This query helps evaluate the cost of technology for each application service.
Starting node: The starting point of the query which is labeled as STARTING NODE on the Query Builder canvas. The first class that you drag to the canvas becomes automatically the starting node of the query and you cannot select a different starting node. In a complex query, the starting node must always be the only node connected to an AND/OR operator. If you try to connect a second node to an operator that the starting node is connected to, the query fails to run and a prompt to select a different starting node appears.
Additional information
- For a webinar, see CMDB Query Builder Queries and Reporting - Platform Analytics Academy blog post in the ServiceNow Community.
- For some tips and basic troubleshooting for the CMDB Query Builder, see the CMDB Query Builder [KB0681251].
Intelligent Search for CMDB integration
By default, Intelligent Search for CMDB functionality is integrated into the CMDB Query Builder. When opening the Query Builder, you can use the Intelligent Search search box which appears above the Query Builder canvas. Intelligent Search lets you use everyday natural language query (NLQ) to build a query. Intelligent Search parses, resolves any ambiguities in table names and relationship types, and then converts your search string into a valid query. The query appears fully constructed on the Query Builder canvas where you can run or continue and develop the query.
The integration of Intelligent Search for CMDB with the CMDB Query Builder is controlled by the system property glide.cmdb.query.nlq.activated, which is set to true by default. If you set the property to false, Intelligent Search for CMDB will not be available within the Query Builder.
AI Search and CMDB
CMDB Query
A query type that queries the infrastructure for CI classes and the relationships and references that connect them. You can optionally add the context of non-CMDB tables to a CMDB query.
- All critical application services in your database.
- All infrastructure in a particular application service.
- All incidents for a particular CI in an application service, or all incidents for all the CIs of an application service.
- All application services with a pattern of a service connected to a database, and where the database has incidents.
The list of available non-CMDB tables includes a subset of tables within the system, which have a reference to the Configuration Item [cmdb_ci] class or its children. The list of non-CMDB tables, includes tables such as Asset, Task, and Problem. You can use the system property glide.cmdb.query.non_cmdb.black_listed_tables to narrow down the list of non-CMDB tables to choose from.
Service Mapping Query
A query type that queries application services. The query is framed within an application service map. You define a pattern, and query for application service maps that have that pattern in their definition. The relationships in Service Mapping queries are matched by single-level direct relationships which is similar to the CMDB queries, and in addition, they are also matched by multi-level indirect relationships if they exist. A query for a relationship between two CI classes is satisfied even if the two CI classes are connected by intermediate CI classes that are not specified in the query.
Combination Query
You can combine the two query types by incorporating a saved Service Mapping query into a CMDB query. For example, create a CMDB query for Windows Servers that are connected to Tomcat WAR. Then connect the Tomcat WAR CI class to a Service Mapping query. The query changes to find Windows Servers that are connected to Tomcat WAR which is included in the services that returned by the Service Mapping query. You can inverse that query by choosing Does Not Belong To Service. This changes the query to find Windows Servers that are connected to Tomcat WAR that is not included in services returned by the Service Mapping query.
Relationship properties
When you connect CI classes on the canvas, the CMDB Query Builder displays the Connection Properties in the right-side bar, where you can configure the properties of the relationship, such as the relationship direction. For Service Mapping queries, you can configure whether to query for related or unrelated CIs.
- Relationship type: Query for CIs and descending classes with specific relationship types.
- Relationship direction: Which CI class is the parent and which CI class is the child in the relationship.
- Relationship level: Query only on first-level relationship or also on second-level relationships.
- No relationships: Query for CIs which have no relationship to the set class.
- References fields: A field that the parent and ancestor parent CI classes use to reference the child CI class.
Newly added relationships between CI classes may take up to 30 minutes to appear in the relationship list.