Description

This article explains the use of regular expression in event policy along with some examples.

 

Regular expressions can be used with the attributes match statement to filter events more precisely.

 

 

Solution

Regular expressions can be used with the attributes match statement to filter events more precisely.

 

Below is the syntax,

 

[edit event-options policy policy-name attributes-match]
event.attribute-name matches regular-expression;
attribute-name: This is the name of the event attribute (e.g. interface-name, bgp-peer, event-message).

regular-expression: Regular expression to match values.

 

Example1:

set event-options policy bgp events bgp_connect_failed
set event-options policy bgp attributes-match bgp_connect_failed.peer-name matches "^192\.168\.1\.[0-9]{1,3}$"
set event-options policy bgp then raise-trap

 

This example matches any BGP peers in subnet 192.168.1.0/24 and then raises a trap message.

 

Example2:

 

set event-options policy interface-flap events snmp_trap_link_down
set event-options policy interface-flap attributes-match snmp_trap_link_down.interface-name matches "^ge-0/0/[0-9]+$"
set event-options policy interface-flap then raise-trap

 

This example matches any interface ranging from ge-0/0/0 to ge-0/0/9 and then raise a trap messag

Modification History

v1