Session Metric Import Script

As of Login Enterprise 5.5, Session Metrics can now be captured from both Windows Performance Monitor and Windows Management Instrumentation. Currently, metrics are only available to add via our API. For more information on Session Metrics and how to import them, please see this article

Overview

This script can be used to automate the process of adding session metric definitions to your Login Enterprise Virtual Appliance until this capability is added in the management console. There was a minor schema change in how PerfMon metrics are defined between 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 have a set of Performance Monitor or WMI performance counters that they rely on to effectively analyze performance of their Virtual Desktop and Application environments. That being said, particular scenarios and analysis may require different performance counters.

For example, when Load Testing, metrics like Disk Queue Length, Error Rates, and Throughput may be more important to measure and analyze before pushing a build into production. On the other hand, during Continuous Testing, metrics like CPU, Memory, and Disk IOPS (among others) may provide adequate context around the user experience.

As an IT Administrator using Login Enterprise to analyze the performance and user experience, I may want to create a Session Metrics Group for each analysis I perform. Currently, the only method to do this is the Swagger API interface.

This script allows Administrators the option to define and import all of their metrics at once or only one subset at a time. The output to can be used to readily access IDs that should be added when creating your Session Metric Groups. In an effort to provide the maximum flexibility, this script will not create or modify existing Session Metric Groups.

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

Note: 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 proper JSON format. Please see the attached sessionMetricDefinitions.txt for an example of the 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 output of the script will return to the user the display name and ID of the newly created Session Metrics. This output aims to 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}

Note: 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 meant to be an ease of use improvement to the alternative process of using the Swagger API interface to manually create each metric individually. That being said, this script does not create a Session Metrics Group, nor add any Metrics to an existing group. Therefore the Swagger interface remains the simplest way to create a Session Metrics Group. 

Simplifying the Session Metrics Group creation process was the purpose of the script's output. Using the example output above, one can directly copy/paste the newly added Session Metric definition's ID into the "definitionKeys" list in the Swagger API interface. An assumption was made that not all users of the script may wish to import and add all metrics to the same group. 

 

Attachments