CMDB - Keep Simple things Simple - Part 4 (Query Builder)

CMDB - Keep Simple things Simple - Part 4 (Query Builder)

Hey Folks,

So here I am with another part of this series for CMDB. We are going to cover "CMDB-Query Builder" in this article and let be very clear on this part- that this blog explains all the relevant concepts right from beginners perspective.

As I observed, CMDB Query Builder is an underestimated tool which can solve our much anticipated work functions like:

  • To know what all CI's are related in a to Database Servers which have Linux running. I mean to say all those queries which have chaining (rather than putting multiple filters in CMDB Tables).This is the same way in which we do Glide Record Queries or build SQL Queries, but here in the more visualized way.

Note: Sometimes it returns CI's and sometimes it returns CI's with Relationships. It depends on the Query as how it is Build.

  • Scheduled Reports ( rather than building Reports under "Report Designer") which can be mailed to Users/Groups at a frequency.
  • Run a partial Query even if you do not want to run the entire query ( this comes in handy when

Now Let's take a look as how the CMDB Query Builder looks like (UI16 Plugin must be activated to use it!!).

What type of Queries can we build in Query Builder?

  • CMDB Queries -In this type of Query, various CI's are returned OR CI's are returned along with their relationships. Example- Below Query retrieves the List of Servers ( Filter: Linux) which are dependent on Databases:

Tip: So when you play purely with CMDB Tables and Relationships, then these are called CMDB Queries. I have understood all along this way!!

  • Service Mapping Queries - These are queries in which we play with Technical Services & Business Services. However for this type of Queries Service Mapping Application has to be pre-activated.

**Both above type of Queries can also be combined.


Building of a CMDB Query 

Step 1: When we drag a first class from "CMDB Artifacts" then it is grayed out and becomes the entry point for CMDB Query( Now you cannot change it. If you Delete it then the next one added becomes the entry point for Query)

Step 2: Drag the 2nd CMDB Class and then draw connector ( hold the box in first class as it turns blue. Then when you hold the box of 2nd class a pop-up appears for defining relationships - we can call it as 'where' condition of SELECT Query) between these 2 classes. 

Step 3:Click on "Run" to view the results. In our case we have finally got 2 results ( we actually got 4 but due to Applied Filter on Server Class of "Linux" only we shortlisted it to only 2):


 Narrowing the list of CI's to be returned

We can infarct place filters on each Classes to narrow our scope of CI's to be finally viewed in the Test Results. In our case we have defined a filter on "Server" Class .

Tip: Use these initial level filters first rather than thinking from filtering based on queries.


What does the line represent?

An interesting point to observe when a guy works in both n CMDB and Service Mapping Queries is the connectors that connects 2 classes.

  • Full Solid Line: This represents a relationship in CMDB Query as we have done in our case:
  • Dotted Line: This represents a relationship in Service Mapping Query.
  • Red Asterisk in middle of Relationship : This happens to both CMDB and Service Mapping Query where relationship is missing.


Queries can be saves by a "Save" button and can be "Duplicated" by a small duplicate icon:

Create a Report and Schedules from Query

Bar Chart and Pie Charts can be built by right-clicking on Test Results (We generally don’t use this):

Schedules of Test Results can be set to be dropped to a Group/User Mailbox at frequent intervals:

Note: No one wants to get Dump in their Inboxes which are related to junk of all CI's. These schedules are important for Alert & Monitoring Teams to monitor the added/removed CI's and checking the health of CI's.

Running Partial Queries

Here comes the most interesting part of Using CMDB Query Builder in which you can highlight a section of full CMDB Query and can execute the results independently ( just like as cropping in MS Paint).

Step 1. Arrange the boxes and highlight the part of query to be executed. As soon as the section is highlighted, the boxes have outlines as BLUE color.

Step 2. Click on "Run" Button and view the Test Results:

So in our case only Server CI's have been returned which are of Class "Linux" as we highlighted this section only.


How does Domain Separation work in CMDB Query Builder?

Now remember one thing - Relationships are not domain separated, however CI's are.

 So here's how domain separation works in various sections of CMDB Query Builder:

  1. Saved Queries: These queries are saved in a table [ qb_saved_query] which is domain separated. So people of same domain as the creator of Query will have these Saved Queries visible.

2. Query Results:  When these have only CI's then results are domain separated. However when these have relationships involved then everything is visible.


Tips to Remember:

  1. Instead of Scheduling Reports for various Teams, use CMDB Query Builder drag and drop interface which teams can also leverage to get their desired data. They just need a role "cmdb_query_builder" in ServiceNow.
  2. When Query takes too much time to retrieve the results, it may result in Timeout. Configure the property out here 'glide.cmdb.query.query_time_limit_in_sec'.

Leave a feedback on below touch ups as how was this blog because "Learning never stops!!". Bye and take care.

Email: [email protected]

Buzz: +1-419-902-3590

WhatsApp: +91-9873300475


要查看或添加评论,请登录

Anubhav Kapoor的更多文章

社区洞察

其他会员也浏览了