Top | Previous | Next |
system.alert.queryAlertHistory |
Description This function queries one of the configured Alert Storage profiles for alert history. The filter arguments help to narrow down the results to alerts that match various criteria, most commonly a range of dates. You can use * to match any number of characters and ? to match a single character in the filter string arguments.
The results of this function are a dataset with the following columns:
This function accepts keyword-style invocation. See also: Functions / Keyword Invocation Syntax system.alert.queryAlertHistory(storageProfile, startDate, endDate, system, path, stateName, minSeverity, maxSeverity, activeAndUnacked, activeAndAcked, clearAndUnacked, clearAndAcked, sortOrder, displayPath) Parameters String storageProfile - The name of the alert storage profile to query. Date startDate - Earliest alert to return. Defaults to 8 hours earlier than current time if omitted. Date endDate - Latest alert to return. Defaults to current time if omitted. String system - Filter string to restrict results based on the alert system. String path - Filter string to restrict results based on the alert path. String stateName - Filter string to restrict results based on the alert state name. Integer minSeverity - Minimum severity to return. Defaults to 0 (Low). Integer maxSeverity - Maximum severity to return. Defaults to 4 (High). Boolean activeAndUnacked - Whether or not to return alerts that are currently active and unacknowledged. Default is true. Boolean activeAndAcked - Whether or not to return alerts that are currently active and have been acknowledged. Default is true. Boolean clearAndUnacked - Whether or not to return alerts that are cleared and unacknowledged. Default is true. Boolean clearAndAcked - Whether or not to return alerts that are cleared and have been acknowledged. Default is true. String sortOrder - The sort order in which to return matching alerts. Either "asc" or "desc", referring to the alert's active timestamp. Default is "desc". String displayPath - Filter string to restrict results based on the alert's display path. Returns Dataset - A dataset containing the historical alert events from the given storage profile that matched the filter and date range arguments. Scope All Examples This code would query an alert storage profile called "DBHistory", looking for the number of unacknowledged alerts in the last 36 hours, displaying the number to the user in a popup message.
from java.util import Date from java.util import Calendar
cal = Calendar.getInstance()
end = cal.getTime() cal.add(Calendar.HOUR, -36) start = cal.getTime()
results = system.alert.queryAlertHistory("DBHistory", start, end, activeAndAcked=0, clearAndAcked=0)
if results.rowCount > 0: system.gui.messageBox("There are %d un-acked alerts!" % results.rowCount)
|