In some cases you do not wish to view the Login Enterprise dashboard at all times. But do want to use the data that is presented in your own custom dashboard. In these cases you want to know how to retrieve this data. This article shows an example of an script based on PowerShell. The file can be found at the bottom of this article.
Requirements
To get this script working correctly we need the following items.
- Login Enterprise URL ($WebURL)
- API Token ($ConfigToken)
- Needs to be configuration permission
- Test GUID ($TestGuid)
These can be found at the beginning of the script.
## Script Variables
$WebURL = "https://Loginenterprise.my.domain"
$ConfigToken = "BifSUhkFfEKkLb7tqnYUtYiNBkaJA4OgrdemwoLM71Q"
$TestGUID = "3a9f24a1-232f-4849-8a37-56117ba82734"
The section after the Script variables contains the certificate an SSL connection setup. By default it ignores certificate errors, so it works with self-signed and official certificates.
Content
The script will execute a number of actions:
- Retrieve the top two launcher locations
- Retrieve diagnostic tile data as found on the dashboard overview for all Continuous Tests (for the last hour)
- Retrieve the diagnostic tile data for a specific Continuous Test (for the last 15 minutes)
- Retrieve Diagnostic tile data for a specific Continuous Test and Launcher combination (for the last hour)
- Retrieve the application statistics for a specific continuous test (for the last hour)
- Retrieve application statistics for a specific continuous test and a specific launcher location (for the last hour)
## Script Variables
$WebURL = "https://Loginenterprise.my.domain"
$ConfigToken = "BifSUhkFfEKkLb7tqnYUtYiNBkaJA4OgrdemwoLM71Q"
$TestGUID = "3a9f24a1-232f-4849-8a37-56117ba82734"
# WARNING: ignoring SSL/TLS certificate errors is a security risk
$code = @"
public class SSLHandler
{public static System.Net.Security.RemoteCertificateValidationCallback GetSSLHandler()
{return new System.Net.Security.RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => { return true; });}
}
"@
Add-Type -TypeDefinition $code
# WARNING: ignoring SSL/TLS certificate errors is a security risk
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = [SSLHandler]::GetSSLHandler()
# this is only required for older version of PowerShell/.NET
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12
# Define global authorization header for the script
$Header = @{
"Accept" = "application/json"
"Authorization" = "Bearer $ConfigToken"
}
## Retrieve location site 1 and 2 in the list. To add more simply copy paste and make changes to the numbers in the []
$Location1 = (Invoke-RestMethod -Uri "$WebUrl/publicApi/v5/locations" -Headers $Header -Method Get).Items[0].id
$Location2 = (Invoke-RestMethod -Uri "$WebUrl/publicApi/v5/locations" -Headers $Header -Method Get).Items[1].id
## Retrieve the diagnostic tile data on the dashboard for all continuous tests for the last hour
Invoke-RestMethod -Uri "$WebUrl/publicApi/v5/test-diagnostics?timeRange=lasthour" -Headers $Header -Method Get
## Retrieve the diagnostic tile data on the dashbnoard for a specific continuous test, for the last 15 minutes
Invoke-RestMethod -Uri "$WebUrl/publicApi/v5/tests/$TestGUID/test-diagnostics?timeRange=last15minutes" -Headers $Header -Method Get
## Retrieve diagnostic tile data based on the location dashboard per site for the last hour, to expand duplicate the entries.
Invoke-RestMethod -Uri "$WebUrl/publicApi/v5/tests/$TestGUID/test-diagnostics?timeRange=lasthour&locationId=$Location1" -Headers $Header -Method Get
Invoke-RestMethod -Uri "$WebUrl/publicApi/v5/tests/$TestGUID/test-diagnostics?timeRange=lasthour&locationId=$Location2" -Headers $Header -Method Get
## Retrieve application statistics for a specific continuous test for the last hour
Invoke-RestMethod -Uri "$WebUrl/publicApi/v5/tests/$TestGUID/application-diagnostics?timeRange=lasthour" -Headers $Header -Method Get
## Retrieve application statistics for a specific continuous test and a specific launcher location, for the last hour
Invoke-RestMethod -Uri "$WebUrl/publicApi/v5/tests/$TestGUID/application-diagnostics?timeRange=lasthour&locationId=$Location2" -Headers $Header -Method Get