How to Access Citrix Monitoring Database Data from Other Applications with O-Data REST API

Now, you can connect and pull the Citrix Monitoring Database data with the O-Data API released by Citrix. Accessing Citrix Monitor Service data using the OData v4 endpoint in Citrix Cloud is currently under preview.
In this article, I will show you how you can pull that data.

Picture Credit:

To do this, you first need to create the Citrix API client. You should also have access to the Citrix Cloud. A Citrix Cloud account is required to use Citrix Cloud Services APIs.

Create an API client

In the Citrix Cloud console, click the menu in the upper left corner of the screen.

Select the Identity and Access Management option from the menu. If this option does not appear, you may not have adequate permissions to create an API client. Contact your administrator to get the required permissions.

A screenshot of a phone

Description automatically generated

Select the API Access tab.

A screenshot of a computer

Description automatically generated

Name your Secure Client, and click Create Client.

The following message appears, ID and Secret have been created successfully. Download or copy the Client Id and Secret. You will need both to access the APIs.

A screenshot of a computer

Description automatically generated

After closing the previous dialog, take a note of the customer ID in the description above the Create Client button. You will also need this to access the APIs.

In the next step, you need to generate an API token.

The PowerShell script to generate an API token is as follows:

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"

$headers.Add("Accept", "application/json")

$headers.Add("Content-Type", "application/x-www-form-urlencoded")

$body = "grant_type=client_credentials&client_secret=[client secret]&client_id=[client id]"

$response = Invoke-RestMethod '[Citrix Customer ID]/tokens/clients' -Method 'POST' -Headers $headers -Body $body

Now you need to extract the access token from the response and store it in a variable. Below is the script to do that.

$access_token = $response.access_token

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"

$headers.Add("Authorization", "CWSAuth bearer=$access_token")
$headers.Add("Citrix-CustomerId", "[Customer ID]")

In the next step, you need to Construct and output the URL on a single line

$requestUrl = "”

URLs for Available Data Sets

URL Description
http://{ApiGatewayEndpoint}/Catalogs Catalog images in the Site
http://{ApiGatewayEndpoint}/ConnectionFailureCategories Grouping for connection failure types
http://{ApiGatewayEndpoint}/ConnectionFailureLogs Log of each connection failure in the Site
http://{ApiGatewayEndpoint}/Connections Represents an initial connection or reconnect for a session
http://{ApiGatewayEndpoint}/DesktopGroups Delivery Groups in the Site
http://{ApiGatewayEndpoint}/FailureLogSummaries Failures (connection/machine) counts by time period and Delivery Group
http://{ApiGatewayEndpoint}/Hypervisors Hosts (hypervisors) in the Site
http://{ApiGatewayEndpoint}/LoadIndexes Load Index data received from the Virtual Delivery Agent (VDA)
http://{ApiGatewayEndpoint}/LoadIndexSummaries Load Index averages by time period and machine
http://{ApiGatewayEndpoint}/MachineFailureLogs Log of each machine failure by start and end date in the Site
http://{ApiGatewayEndpoint}/Machines Machines in the Site
http://{ApiGatewayEndpoint}/SessionActivitySummaries Session counts and logon data by time period and delivery group
http://{ApiGatewayEndpoint}/Sessions Represents a user connected to a desktop
http://{ApiGatewayEndpoint}/TaskLogs Log of all tasks and their status that have been run as part of the internal Monitor Service
http://{ApiGatewayEndpoint}/Users Users that have launched a session in the Site
http://{ApiGatewayEndpoint}/ProbeRules Application probes configured in the Site
http://{ApiGatewayEndpoint}/ProbeEndpoints Machines running Citrix Probe Agent to probe applications in the Site
http://{ApiGatewayEndpoint}/ProbeLogs Results of probes run per application
http://{ApiGatewayEndpoint}/ProbeResults Results of probes run (with failure stage) per application
http://{ApiGatewayEndpoint}/LogOnMetrics Timestamps related to Interactive Session breakdown

Now, in the next step, you need to send the API request

$response = Invoke-RestMethod $requestUrl -Method ‘GET’ -Headers $headers

And in the last step, you need to convert that API response to JSON.

$response | ConvertTo-Json

That’s all for today, and thanks for reading this one, I hope you will like this post. You have a great day ahead of you.