The XenApp and XenDesktop environment on Citrix Cloud gathers a large amount of historical data in the Monitoring Database. Until now, you could access some of this data via the Director Trends and Custom reports. Creating customized queries to directly access the db has been a much sought-after feature.

This month, we decided to bring it to you via the new OData API that enables you, as a XenApp and XenDesktop administrator, to create your own queries for the monitoring data to suit your requirements.

This API can be used to:

  • Build custom analysis tools on historical trends for future planning.
  • Create custom user interface on top of the data that the API provides.
  • Aggregate the data to generate a consolidated report.
  • Get customized reports in Excel PowerQuery and other tools.

The following example shows how you can use Postman REST client to query this endpoint.

Let’s walk through some sample use cases:

  • Consider a situation where an administrator wants to retrieve the list of all the users taking more than 10 minutes to login. An OData query to get this data would look like:https://{customername}$filter=Sessions/any(session: session/LogOnDuration gt 600000)
    A report generated using this query in Excel looks like:

  • The highlight of this API is that it supports most of the data aggregation functions like min, max, and count; so you can get a consolidated result. Let’s say you want to build a simple UI that shows the number of sessions in connected, disconnected, and reconnecting states. Without the support of aggregate functions, you would have to query for 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. An OData query for such request can be written as:

    https://{customername}$apply=groupby((ConnectionState), aggregate(SessionKey with countdistinct as NumberOfSessions))
    If queried using Excel’s PowerQuery, here is how the report looks.