To query all events from an event group, use the queryEventsByEventGroup(String,
String, boolean) method of the EventAccess bean.
Why and when to perform this task
Steps for this task
- If you need to create an event access bean, see Creating an event access bean.
- Call the EventAccess.queryEventsByEventGroup(String, String, boolean)
method.
CommonBaseEvent[] events = eventAccess.queryEventsByEventGroup(eventGroup,
eventSelector,
ascendingOrder);
The parameters of this method are as follows:
- eventGroup
- A string containing the name of the event group you want to query events
from. This must be the name of an existing event group defined in the event
infrastructure configuration.
- eventSelector
- A string containing an optional event selector that further refines the
query. The query returns only events that match both the specified event group
and the additional event selector. An event selector is specified in the form
of an XPath expression (for more information, see Writing event selectors).
If you do not want to specify an additional event selector, this parameter
can be null.
- ascendingOrder
- A boolean value specifying whether the returned events are to be sorted
in ascending or descending order according to the value of the creationTime
property. If this parameter is true, the events are sorted in ascending
(chronological) order; if it is false, they are sorted in descending
(reverse chronological) order.
The returned object is an array
containing the events from the specified event group.
Note: If the number
of matching events exceeds the query threshold defined in the data store profile,
a QueryThresholdExceededException exception is thrown. The default query threshold
is 100 000.
Example
The following code fragment returns all events that belong to
an event group called
critical_hosts and whose severity is greater
than 30 (warning):
CommonBaseEvent[] events =
eventAccess.queryByEventGroup("critical_hosts",
"CommonBaseEvent[@severity > 30]",
true);