Correlating Events
You can configure a policy that correlates two or more events. If the correlated events occur as specified, they cause particular actions to be taken. For example, you might want to issue certain operational mode commands when a UI_CONFIGURATION_ERROR event is generated within five minutes (300 seconds) after a UI_COMMIT_PROGRESS event. As another example, you might want to upload a particular file if a DCD_INTERFACE_DOWN event is generated two times within a 60-second interval.
To configure a policy that correlates events, include the following statements at the
[edit event-options]hierarchy level:[editevent-options]policypolicy-name{events [events];withinsecondsnotevents[events];attributes-match{event1.attribute-nameequalsevent2.attribute-name;event.attribute-namematchesregular-expression;event1.attribute-namestarts-withevent2.attribute-name;}}In the
eventsstatement, you can list multiple events. To view a list of the events that can be referenced in an event policy, issue theset event-options policypolicy-nameevents ?configuration mode command:user@host#set event-options policypolicy-nameevents ?Possible completions:<event>[ Open a set of valuesacct_accounting_ferroracct_accounting_fopen_error...In addition, you can reference internally generated events, which are discussed in Generating Internal Events.
The actions configured in the
thenstatement are executed only if certain conditions are met, which you specify in thewithinandattributes-matchstatements.You can configure a policy that is executed only if a specified event occurs within a specified time interval after another event. You do this by including the
withinsecondseventsstatement. The policy is executed only if one or more of the events in the firsteventsstatement occur within a configured number of seconds after one or more of the events in thewithinsecondseventsstatement. The number of seconds can be from 60 through 604,800. Thenotstatement causes the policy to be executed only if the events do not occur within the configured time interval.For example, the following policy is executed if
event3,event4, orevent5occurs within 60 seconds afterevent1orevent2occurs:event-options {policy 1 {events [event3event4event5];within 60 events [event1 event2];then {...}}}The
attributes-matchstatement correlates two events as follows:
event1.attribute-nameequalsevent2.attribute-name—Execute the policy only if the specified attribute ofevent1equals the specified attribute ofevent2.event.attribute-namematchesregular-expression—Execute the policy only if the specified attribute ofeventmatches a regular expression. For more information, see Using Regular Expressions to Refine the Set of Events That Cause a Policy to Be Executed.event1.attribute-namestarts-withevent2.attribute-name—Execute the policy only if the specified attribute ofevent1starts with the specified attribute ofevent2.You can include the
attributes-matchstatement only if you include one or morewithinstatements in the same policy configuration. This means the events are correlated only if they occur within a specified time period.To view a list of all event attributes that you can reference, issue the
helpsyslogeventoperational mode command. The output of this command shows the event attributes in angle brackets (<>). The following output shows that three attributes can be referenced for the ACCT_ACCOUNTING_SMALL_FILE_SIZE event: filename, filesize, and record-size.user@host>help syslog ACCT_ACCOUNTING_SMALL_FILE_SIZEName: ACCT_ACCOUNTING_SMALL_FILE_SIZEMessage: File <filename> size (<filesize>) is smaller than record size (<record-size>)Another way to view the attributes you can reference is by issuing the
set attributes-matchevent?command at the[edit event-options policypolicy-name]hierarchy level, as shown in the following example:[edit event-options policy p1]user@host#set attributes-match acct_accounting_small_file_size?Possible completions:<from-event-attribute> First attribute to compareacct_accounting_small_file_size.filenameacct_accounting_small_file_size.filesizeacct_accounting_small_file_size.record-sizeFor configuration examples, see Ignoring Events Based on Receipt of Other Events, Correlating Events Based on Event Attributes, and Controlling Event Policy Using a Regular Expression.