SOLVED: Alerts and API: How to update the targets of the Alert Suppression Window

BorruBorru Posts: 3 New member
edited January 25, 2023 7:38AM in Redgate Monitor
Dear all,

I have two questions which are connected:
1. If the host machine (which may run several instances) is in a downtime window and the instances are not, will the instances still raise alerts or are they suppressed as the host machine is already in a downtime window?

2. How can I update the Targets of a configured Alert Suppression Window with the help of the Powershell API:
We have patch days here and a subset of machines machines are in different patch day groups.

I have configured to suppress alerts based on tags for the instances, but since only instances can be tagged and host machines not, I want to update the alert suppression windows with the help of the powershell API to include the host machine.

I have tried the following:
  • Create a new array, add the machine from the objects I get from Get-SqlMonitorMachine and then assign this array to the "Targets"-Property of the object I get from Get-SqlMonitorAlertSuppressionWindow like this:
    $machine = Get-SqlMonitorMachine<br>$window = Get-SqlMonitorAlertSuppressionWindow -Name WindowName<br>$targets = $window.Targets<br>$newTargets = @($targets,$machine[0])<br>$window.Targets = $newTargets

  • Set only the machine object like this:
    $machine = Get-SqlMonitorMachine<br>$window = Get-SqlMonitorAlertSuppressionWindow -Name WindowName<br>$window.Targets = $machine[0]
Both didn't work. Unfortunately the documentation of the cmdlet (https://documentation.red-gate.com/sm/api/powershell-api/powershell-cmdlet-reference/update-sqlmonitoralertsuppressionwindow) doesn't help here as it only clears the Targets.

Kind Regards,
Borru
Tagged:

Comments

  • BorruBorru Posts: 3 New member
    Okay, 

    the first question is answered as we tried it yesterday:
    If the machine (host) is in a alert suppression window, the instances will not raise any alerts.

    The second question on how to add a machine as a target for the update-sqlmonitoralertsuppressionwindow cmdlet is still open.

    Kind Regards,
    Borru
  • BorruBorru Posts: 3 New member
    Second Question is also answered. I was finally able to find out how to update the targets. For anyone interested, this is how you do it:

    $alertSuppressionWindow = Get-SqlMonitorAlertSuppressionWindow -Name $WindowName
    $alertSuppressionWindow.Targets += $machine[0]
    $alertSupressionWindow | Update-SqlMonitorAlertSuppressionWindow$machine = Get-SqlMonitorMachine
    

    Kind Regards,
    Borru
  • Hi Borru,

    Apologies we didn't respond to you sooner, looks like there was a brief issue with the mechanism that generates tickets internally from our forum. Glad you were able to resolve this, please let us know if you require any further assistance with SQL Monitor.
    Kind regards

    Tom Claringbold | Redgate Software
    Have you visited our Help Center?
Sign In or Register to comment.