Is there a way to pull Device Instance Escalation Chains #7
-
Wondering if there is a way to pull the escalation chain that would be triggered for any static / dynamic thresholds configured? I cannot seem to find anything in the documentation and none of the modules hint towards the device/resource's instances escalation chain - only the escalation chains configured in the settings pane. Any help would be appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I believe the endpoint your looking for is Function Get-LMDeviceDatasourceInstanceAlertRecipients {
[CmdletBinding()]
Param (
[Parameter(Mandatory, ParameterSetName = 'Id-dsName')]
[Parameter(Mandatory, ParameterSetName = 'Name-dsName')]
[String]$DatasourceName,
[Parameter(Mandatory, ParameterSetName = 'Id-dsId')]
[Parameter(Mandatory, ParameterSetName = 'Name-dsId')]
[Int]$DatasourceId,
[Parameter(Mandatory, ParameterSetName = 'Id-dsId')]
[Parameter(Mandatory, ParameterSetName = 'Id-dsName')]
[Int]$Id,
[Parameter(Mandatory, ParameterSetName = 'Name-dsName')]
[Parameter(Mandatory, ParameterSetName = 'Name-dsId')]
[String]$Name,
[Parameter(Mandatory)]
[String]$InstanceName,
[Parameter(Mandatory)]
[String]$DataPointName
)
#Check if we are logged in and have valid api creds
If ($Script:LMAuth.Valid) {
#Lookup Device Id
If ($Name) {
$LookupResult = (Get-LMDevice -Name $Name).Id
If (Test-LookupResult -Result $LookupResult -LookupString $Name) {
return
}
$Id = $LookupResult
}
#Lookup Hdsid
If ($DatasourceName -or $DatasourceId) {
$LookupResult = (Get-LMDeviceDataSourceList -Id $Id | Where-Object { $_.dataSourceName -eq $DatasourceName -or $_.dataSourceId -eq $DatasourceId }).Id
If (Test-LookupResult -Result $LookupResult -LookupString $DatasourceName) {
return
}
$HdsId = $LookupResult
}
#Lookup HdsiId
If ($DatasourceName) {
$LookupResult = (Get-LMDeviceDatasourceInstance -DatasourceName $DatasourceName -DeviceId $Id | Where-Object { $_.name -like "*$InstanceName"}).Id
If (Test-LookupResult -Result $LookupResult -LookupString $InstanceName) {
return
}
$HdsiId = $LookupResult
}
Else{
$LookupResult = (Get-LMDeviceDatasourceInstance -DatasourceId $DatasourceId -DeviceId $Id | Where-Object { $_.name -like "*$InstanceName"}).Id
If (Test-LookupResult -Result $LookupResult -LookupString $InstanceName) {
return
}
$HdsiId = $LookupResult
}
#Get datapoint id
$LookupResult = (Get-LMDeviceDatasourceInstanceAlertSetting -DatasourceId $DatasourceId -Id $Id -InstanceName $InstanceName | Where-Object { $_.dataPointName -like "*$DataPointName"}).Id
If (Test-LookupResult -Result $LookupResult -LookupString $DataPointName) {
return
}
$DsidpId = $LookupResult
#Build header and uri
$ResourcePath = "/device/devices/$Id/devicedatasources/$HdsId/instances/$HdsiId/alertsettings/$DsidpId/recipients"
#Initalize vars
$Results = @()
Try {
$Headers = New-LMHeader -Auth $Script:LMAuth -Method "GET" -ResourcePath $ResourcePath
$Uri = "https://$($Script:LMAuth.Portal).logicmonitor.com/santaba/rest" + $ResourcePath
Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation
#Issue request
$Response = Invoke-RestMethod -Uri $Uri -Method "GET" -Headers $Headers[0] -WebSession $Headers[1]
}
Catch [Exception] {
$Proceed = Resolve-LMException -LMException $PSItem
If (!$Proceed) {
Return
}
}
Return $Response
}
Else {
Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again."
}
}
|
Beta Was this translation helpful? Give feedback.
I believe the endpoint your looking for is
GET - /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{instanceId}/alertsettings/{instancedatapointid}/recipients
. I don't believe its an officially supported endpoint as its not present in the v3 swagger docs but I would suggest putting in a feature request to have them add that as I can see it being useful to have. In the meantime you can try this above cmdlet with the Logic.Monitor PS module and it should get you what your looking for. Im not sure this will end up in the module since its technically an unsupported endpoint but feel free to use as needed: