We've noticed something about the behavior of alerts that have maintenance windows set up.
So if an alert is triggered during a maintenance window no trigger actions are performed and the alert does not show up on the All Active Alerts page. So far so good. When the maintenance window ends and the alert is still active no trigger actions are performed and the alert doesn't show up on the All Active Alerts page. Now we have a problem. For example:
- We set up an alert to monitor SQL processes on a database server and we add a maintenance window for 2:00 AM to 3:00 AM each day.
- The server enters its maintenance window and the SQL processes are stopped at 2:15 AM. No alert notification or trigger actions.
- The SQL processes fail to restart as expected at 2:45 AM and the processes are still down when the maintenance window ends at 3:00 AM.
- No alerts notification or trigger actions.
What we'd like to happen is for the alert to show up on the All Active Alerts page and fire off its trigger actions if it's still active at the end of the maintenance window.
Our current workaround is complex and I'm hoping there is something simple we are missing to make the solution much more elegant.
Our current workaround:
- Enable complex conditions for the alert.
- Create the first section as you normally would. Create the scope and trigger conditions for your alert.
- Add a second section to the alert and set the operation between the two to 'AND'
- Set the second section to "Custome SWQL Alert"
- use the following SWQL to create a maintenance window:
<Start SWQL>
-- Days of the week: Sunday = 0, Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6
-- Hours based on a 24-hour day, no AM or PM
-- Maintenance Windows setup in this example
-- Wed 2:59AM - 6:30AM
-- Fri 2:59AM - 5:15AM
WHERE NOT (
((WeekDay(getdate()) = 3) AND ((Hour(getDate())= 2 AND Minute(getdate()) > 58) OR (Hour(getdate()) = 3) OR (Hour(getdate()) = 4) OR (Hour(getdate()) = 5) OR (Hour(getdate()) = 6 AND Minute(getdate()) < 31)))
OR ((WeekDay(getdate()) = 5) AND ((Hour(getDate())= 2 AND Minute(getdate()) > 58) OR (Hour(getdate()) = 3) OR (Hour(getdate()) = 4) OR (Hour(getdate()) = 5 AND Minute(getdate()) < 16)))
)
<END SWQL>
How this all works:
Due to the 'AND' statement, both sections must be true for the alert to trigger. The maintenance statement in section 2 is false during the maintenance window, keeping the alert from triggering during that time. When you exit the maintenance window control of the alert triggering is returned to your trigger conditions in section 1 because the maintenance section is now true.