ControlUp Scoutbees is a cloud-based solution that uses continuous synthetic transaction testing to proactively alert you when the availability of your apps, desktops and network resources are impacted.
Although many customers love using Scoutbees with the current capabilities, some customers asked us to extend Scoutbees to better integrate with their DevOps process. Last year we introduced an API to integrate Scoutbees with the DevOps process to retrieve Scoutbees data and automate the creation of additional scouts. Now we have further integrated Scoutbees to be piloted from your CI/CD pipelines. For instance, Scoutbees provides a built-in maintenance window where we pause the monitoring of a service but some customers want a CI/CD program to programmatically stop monitoring a service while an emergency patch is being deployed outside a scheduled maintenance window and restart monitoring after the service has started.
This article is going to provide you with a solution that we provided to a customer to allow them to pilot their Scout from their continuous integration, continuous delivery (CI/CD) pipelines.
As you can see in the below screenshot, the scheduled maintenance windows are easy to create from the console:
You can also disable / enable your scouts every time you need using the console
How cool it would be if you could integrate this task in your CI/CD pipelines. Meaning that you would stop monitoring and alerting when you start an upgrade and restart the testing and alerting straight after it. That’s exactly what a customer asked me and I provided a simple PowerShell script to do so.
Step 1: Create an API key
The first thing to do when dealing with APIs is authentication, from the console you can create API keys to be used in your scripts. This is accessible from this menu:
Once there, you just need to click on “Create API Key” and give it a name:
Once the API Key is created you can copy it and store it securely since it’s a secret that give access to your Scoutbees tenant on your behalf. You would not put your password on a piece of paper, so don’t do it with your API keys
Step 2: Create a script
The honeycomb is the API for Scoutbees. The documentation is available at https://scoutbees.io/honeycomb/v1
[CmdletBinding()] Param( [Parameter( Position=0, Mandatory=$true )] [string] $ScoutName, [Parameter( Position=1, Mandatory=$false )] [Boolean] $Disabled=$true )
if (-Not (Test-Path ./Scoutbees.key)){ Read-Host "Enter API Key for Scoutbees" -AsSecureString | ConvertFrom-SecureString | Out-File ".\Scoutbees.key" } $ScoutbeesAPIKey =Get-Content ".\Scoutbees.key" | ConvertTo-SecureString $ScoutbeesAPIKey = ([PSCredential]::new(0, $ScoutbeesAPIKey).GetNetworkCredential().Password)
We first check if there is a scoutbees.key file in the current folder and if not, we request for the API key and store it into the file.
$Headers = @{ "x-scoutbees-key"=$ScoutbeesAPIKey "Content-Type"="application/json" }
$ScoutbeesAPIServers = "https://api.scoutbees.io/honeycomb/v1/","https://api.eu.scoutbees.io/honeycomb/v1/" $ScoutbeesCorrectAPIServer = "" $Scouts = @() foreach($ScoutbeesAPIServer in $ScoutbeesAPIServers){ try { $URL = $ScoutbeesAPIServer + "scouts?disabled=1" Write-Output "Trying to connect with to $URL using provided API key" $Temp = invoke-WebRequest $URL -Method GET -Headers $Headers $Scouts = ($Temp.Content | ConvertFrom-Json).Data $URL = $ScoutbeesAPIServer + "scouts?disabled=0" $Temp = invoke-WebRequest $URL -Method GET -Headers $Headers $Scouts += ($Temp.Content | ConvertFrom-Json).Data $ScoutbeesCorrectAPIServer = $ScoutbeesAPIServer break } catch { Write-Output "Not authorized on $URL" } } if ("" -eq $ScoutbeesCorrectAPIServer){ throw "Error - Can't connect to any API endpoint with provided API key" } write-output "We found the correct API server and $($Scouts.count) scouts"
We try to connect to both available API servers (in the US and in EU) and detect if our API works on one of them.
write-output "Looking for scoot $ScoutName" $TargetScout = $Scouts | Where-Object {$_.scoutName -eq $ScoutName} if ($TargetScout.count -ne 1){ throw "Can't determine the Scout to work with" }
Check for the right scout using the ScoutName parameter.
$URLScout = $ScoutbeesCorrectAPIServer + "scouts/$($TargetScout.scoutId)/disabled" write-output $URL $Body = " { `"disabled`": $($disabled.tostring().ToLower()) }" try{ $temp = Invoke-WebRequest $URLScout -Headers $Headers -Method POST -Body $Body -ContentType "application/json" Write-Output "Scout $($TargetScout.scoutName) has been set to disabled $Disabled" } catch{ Write-Error "An error occurred while trying to perform the requested operation" throw $_ }
In this article I gave you some insights into how our customers are programmatically integrating Scoutbees with their CI/CD pipeline. If you have any questions, reach out to us so we can show you how ControlUp Scoutbees synthetic transaction testing proactively alerts you when the availability of your apps, desktops and network resources are impacted.