Ever wondered how to get answers for queries like…

How many Users are active in each location?

How many users are experiencing slow logins to their XenApp applications?

If you answered “yes,” Citrix has some good news for you!

With Citrix Director 7.16, we have introduced a new OData API for XenApp and XenDesktop’s Monitor Service, which is a superset of all the previous ones. In addition to that, it can handle most of the aggregation queries like min, max and count which was not a part of previous OData APIs. In addition to using Director, administrators can use this API to build custom UI to analyse trends and to perform advanced OData queries on Monitor Service’s data.

Here are some of the improvements done in this API compared to previous ones.

  • Improved Queryability : Adds many extensions for filters, sorts and expands.
  • Aggregation Support : Administrators are now able to get consolidated report regarding their environment which is better suited for analysis.

Let’s walk through some sample use cases:

Use Case #1 : Consider an administrator who wants to build a simple UI which shows the number of sessions in connected, disconnected, and reconnecting states. Without the support of aggregate functions, administrator would be left with no option but to query each state for data. The new API facilitates grouping and aggregation based on required fields and reduces the number of requests to be made to get the result. OData query for such request can be written as:

https://{dc-host}/Citrix/monitor/odata/v4/data/Sessions?$apply=groupby((ConnectionState), aggregate(SessionKey with countdistinct as NumberOfSessions))

If queried using Excel’s PowerQuery, here is how the report looks

Use Case #2 : An administrator wants a report of number of unique users who have logged in since 1st July 2016. Here is how the odata query would look like :

https://{dc-host}/citrix/monitor/odata/v4/data/Sessions?$apply=filter(StartDate ge 2016-07-01T00:00:00z)/groupby((User/UserName))&$count=true

In addition to listing the users, result will also include the number of users in @odata.count key.

If queried using a REST client, here is how the result looks like:

Notes: