Does anyone know how I would obtain the Alert UUID for active alerts?
Under the Rest API documentation for alerts it says you need the 'Alert UUID' to pull alert notes. How exactly does one obtain alert uuid's?
Many Thanks
The alert UUID is in the alert notifications, it is also given when you query the API for alerts.
Could you be more specific? From the vROPS GUI, I don't see any tab that shows alert UUID's. Therefore, when I get alerts from the API, I cannot verify if what I think is the UUID, is actually the UUID.
Under the Alerts section, if you click on the columns, you can place a check in front of the Alert ID. This will show the UUID in front of all the triggered alerts.
I'm not all to sure if you want the API for this or what was suggested... But if API is your way, have a look at this script I used to mappe datastore alert to datastore cluster as an example.
#Variables
$username = "admin"
$password = "password"
$vRops = "vRopsFQDN"
#vRops SSL certificate trust
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
#Convert username and password till securestring
$secPw = ConvertTo-SecureString $password -AsPlainText -Force
$cred = New-Object PSCredential -ArgumentList $username,$secPw
#Call vRops API
$res = Invoke-RestMethod -Method Get -Uri "https://vRopsFQDN/suite-api/api/resources/?pageSize=5000" -Credential $cred
$alert = Invoke-RestMethod -Method Get -Uri "https://vRopsFQDN/suite-api/api/alerts/?pageSize=5000" -Credential $cred
#Script start
#($alert.alerts.alert |where {$_.status -match "active" -and $_.alertDefinitionName -match "Datastore is running out of disk space"})
#(($res.resources.resource.resourceKey | where {$_.resourceKindKey -match "StoragePod"}) | Select Name,@{E={$_.resourceIdentifiers.resourceIdentifier[1].value};L="OID"})
$DSClusterAlert = @()
Foreach($AlertID in (($alert.alerts.alert | where {$_.status -match "active" -and $_.alertDefinitionName -match "Datastore is running out of disk space"}).resourceId)){
$Details = "" | Select Name
$Details.Name = ((Invoke-RestMethod -Method Get -Uri "https://vRopsFQDN/suite-api/api/resources/$AlertID/relationships/parents" -Credential $cred) | where {$_.'resource-relation'.resource.resourceKey.resourceKindKey -match "StoragePod"}).'resource-relation'.resource.resourceKey | where {$_.resourceKindKey -match "StoragePod"} | select Name
$DSClusterAlert += $Details
}
$DSClusterAlert.Name | Group-Object Name | select Name,Count