Thank you for your feedback.
Form temporarily unavailable. Please try again or contact docfeedback@servicenow.com to submit your comments.

Querying the CMDB

Log in to subscribe to topics and get notified when content changes.

Querying the CMDB

The CMDB Query Builder allows you to easily build complex infrastructure and service queries that span multiple CMDB classes, 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 CIs of a certain type in a business 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 business service.
  • All Servers with a database.
  • All database servers that are included in any business service or in a particular business service.
  • All business services and their associated servers and the cost of each server. This query helps evaluate the cost of technology for each business service.

A start node in the Query Builder is the starting point of the query and is noted by gray background in its query node. The first class that you drag to the canvas becomes automatically the start node of the query and you cannot select a different start node. In a complex query, the start 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 start node is connected to, the query fails to run and a prompt to select a different start node appears.

CMDB Query

A query type that queries the infrastructure for CI classes, and the relationships and references that connect them.

Service Mapping Query

A query type that queries business services and technical services, and thus requires that Service Mapping is activated. The query is framed within a business service map. You define a pattern, and query for business 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.

Connection properties include:
  • 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.

Feedback