The CMDB Query Builder allows you to easily build complex infrastructure and service queries that span multiple CMDB classes, and that involves many CIs that are connected by different relationships.
Users can access the Query Builder by searching for ‘CMDB Query Builder’ in the left menu. This module can export multilevel relationships for a CI name. This is a UI only feature, there is no mobile interface. There is the ability to create a schedule and receive query results in an email report. The REST API that supports this feature is not publicly available.
The feature supports domain separated CMDBs. All results are shown to the user adhere to ACL rules in the system.
The CMDB Query Builder provides a canvas into which you drag the CI classes and other artifacts 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.
1. If a query takes too long to process, how can I debug it?
By adding the system property 'glide.cmdb.logger.use_syslog.QueryBuilderProcessor' with value - *, verbose debugging can be turned on to determine what happened.
Processing times and error messages are logged with the source name QueryBuilderProcessor.
By default, the processing has a five-minute time out on each query batch.
2. What are the system properties available with this feature?
3. What is the significance of the ‘start node’ in the query? Why am I prompted to pick one sometimes?
The node with the grey background denotes a ‘Start Node’. This is the node we start the query with. By default the first node dropped on the canvas is the start node.
A query graph can have only one start node.
This node has to be on the common side of an operator, and if possible, it should not have an incoming connection. If a graph is drawn where the start node is on the multiple sides of an operator or has an incoming straight connection, the user is prompted to pick a new start node.
4. How is the drop down of the suggested relationships between two classes defined? I just added a new relationship between two classes, why I don’t see that relation type as an option?
The suggested relations are added to guide the users in creating queries that return valid results.
The CI Relations table is parsed on a scheduled basis (every 30 minutes) to create a list of existing relationship types between each pair of classes.
The results are stored in the cmdb_class_relationships table.
If the user does not want to wait for 30 minutes for the newly created relationship type to show up, the entry in the cmdb_class_relationships table can be deleted.
When the query builder UI is loaded again, it will be refreshed.
5. Why don’t I see suggested relationships for service queries?
In service maps, users are not shown the exact relationship type between services, because of which they are not always aware of the exact relationship type between elements.
6. Some queries give this error message – “Problem running query. Error parsing edge”. Why?
The query engine can parse queries that either fan out with operators, or fan in. Queries with two operators which share nodes of the multiple sides of the operator are not supported in this release. Below are some examples of valid and invalid queries.
7. Are there any other kinds of queries that are not supported?
Queries with loops are not supported.
Do I need the Service Mapping plugin to create service queries?
Yes, service queries only work with Service Mapping service maps.
8.Why are connection lines dotted in service mapping queries?
In services, we don’t just look at level 1 relationships between elements.
Because we know the boundary of the service, we continue looking of n-level relationships to see if the elements are connected; this is why the line is dotted.
9.When I export the query result, the file is in CSV format. Can I export results in any other format?
No, only in CSV format for exports.
10. What access control does this feature have?
The user needs the role cmdb_query_builder to access this feature.
11. Can I drop the CMDB_CI class in my query?
Yes, but it is advisable not to. Queries with the parent cmdb_ci class will take longer to run.
12. How can I turn on additional logging for my queries?
There is a system property that can turn on verbose logging.
The log source is QueryBuilderProcessor and QueryBuilderOutput
Name: glide.cmdb.logger.use_syslog.QueryBuilderProcessor. Value - *
Name: glide.cmdb.logger.use_syslog.QueryBuilderOutput. Value - *
13. Do ACL's honor when using CMDB Query?
Yes, they do, for example:
Create a new test query which is the same as "Xyz" add the column called Name and it should work fine.
Add more columns and the test query "Xyz" will throw the 'Problem running query' instead of showing the result. Therefore, the issue is the user has no permission to visit some reference table of the fields in the classes that are involved.
Narrow down which column has caused the issue and fix the ACLs if they want to add the column to the result or just remove the column from the query to make it work. From the stack trace, we also know the exception happens when reading the table reference.
The best practice is to only add the columns which need to be shown in the result.