Session Metric Import Script

Overview

Example usage

Code explanation

Example output

Next steps

Additional resources

Overview

As of Login Enterprise 5.5, Session Metrics can now be captured from both Windows Performance Monitor and Windows Management Instrumentation. You can add these metrics both via the API and the Login Enterprise user interface. For more information on Session Metrics, see the Session Metrics

To automate the process of adding Session Metric definitions to your Login Enterprise Virtual Appliance via the API, you can use the Session Metrics import script. There was a minor schema change in how PerfMon metrics are defined between Login Enterprise 5.4 and 5.5, but this script handles both scenarios.

The script outputs the name and ID of each created Session Metric, aimed at improving ease of use for those relying on manual efforts within the Swagger API interface. 

Example usage

Many IT administrators rely on Performance Monitor or WMI performance counters to analyze the performance of their virtual desktop and application environments effectively. Different scenarios and analyses may require different performance counters.

For example, when conducting Load Testing, metrics such as Disk Queue Length, Error Rates, and Throughput are crucial for assessing performance before pushing a build to production. In contrast, during Continuous Testing, metrics like CPU, Memory, and Disk IOPS can provide valuable insights into user experience.

As an IT administrator using Login Enterprise to analyze performance and user experience, you might consider creating a Session Metrics Group for each analysis. If you prefer to do this using the Swagger API interface, you will need a Session Metric import script.

This script allows administrators to define and import all their metrics at once or in subsets. The output provides IDs that should be added when creating Session Metric Groups. For maximum flexibility, the script does not create or modify existing Session Metric Groups.

.\ImportSessionMetrics.ps1 -filePath "\pathToMyJSON.txt" -fqdn "myappliance.contoso.com" -token "nsc24-lfcCjkYwRRq1VmPiWrevWiXVe29TTabPTlCgE"

Because this functionality is only available in the v7-preview API, this script is subject to breaking changes. The script may or may not be updated to handle those breaking changes at the moment.

Code explanation

The script accepts three parameters: 

  • FilePath: The path to a file containing valid JSON objects, defining Session Metrics to add
  • FQDN: The URL of your Login Enterprise Virtual Appliance, excluding the protocol and API path
  • Token: A Configuration-level API access token created on your Virtual Appliance

First, the script starts by getting the raw content of the provided text file. The text file must be in proper JSON format. Please see the attached sessionMetricDefinitions.txt for an example of the schema.

For each JSON object in the provided text file, the raw JSON is extracted and used as the request body when performing a POST request with the API to create the Session Metric definition. 

After each metric definition is created, there is additional logic to extract the display name and the ID of the newly created Session Metric for output to simplify the group creation process.

Example output

The script will output the display name and ID of the newly created Session Metrics. This output helps simplify the process of creating a Session Metric Group.

SSL Handler already exists.

id name
-- ----
53269d1c-274a-42e3-9bc4-64592fb031cb Disk Transfers/sec
671d6711-3ac2-4d37-acee-d4f31e3ace9d {Avg Writes Per Sec, Avg Reads Per Sec}

This example shows the output of the SSLHandler definition which allows the script to bypass certificate validation. This may not meet your organization's security requirements. 

Next steps

This script is designed to simplify the process compared to manually creating each metric through the Swagger API interface. However, it does not create a Session Metrics Group or add metrics to an existing group. For creating a Session Metrics Group, the Swagger interface remains the most straightforward option.

The script’s output aims to streamline the creation process by providing the display name and ID of newly created session metrics. Using this output, you can easily copy and paste the ID of the newly added Session Metric definition into the "definitionKeys" list in the Swagger API interface. Note that the script assumes not all users will want to import and add all metrics to the same group.

Frame 543.png

Additional resources