Using UI Queries for Reporting in Foglight

A UI Query can be used as an input to a report. This can simplify and offer a broader range of inputs when running or scheduling a report.

For a refresher on creating UI Queries, this post  covers the basics. 

WCF reports have inputs in order to properly execute the report. The part in the red box below shows that this example takes a data type of "Monitoring:MongoServer". That is, if there is a UI Query marked public, it will be available as an option when running this report. Within MongoDB, there are 2 types of MongoServers - Mongos (Mongo-ess) and Mongod (Mongo-dee). In the animation below, I will build a UI query that only returns MongoD servers.

When you run a report, you are prompted with the inputs (required and optional).

The input type is also shown when you pick from the dropdown. If there are public UI queries that match the input type, they will be shown instead:

From there, the query results can be expanded and a specific server can be selected for the report:

The animation below shows the steps taken to build the UI Query that was used above:

But wait, there's more! 

The data type this query returns in MongoServer, and under the path of MongoDBRoot/clusters, there are 2 nodes that return a list of MongoServers - mongoD and mongoS. We can combine those into a single query by leveraging the Max Search Depth value. Fair warning.. going beyond a depth of 2 could seriously impact performance. In this case, level 1 will suffice. It basically tells the query to start at MongoDBRoot/clusters, and search 1 level down to find a match or matches.

Testing the query now produces a list containing both MongoS and MongoD servers!