elastalert icon indicating copy to clipboard operation
elastalert copied to clipboard

Understanding Filter AND & OR condition

Open sathishdsgithub opened this issue 9 years ago • 4 comments

@Qmando

I would like to understand the difference between these two conditions. Both the rules responses in a different way.

What I notice is in Rule 1 the term "RT_FLOW_SESSION_DENY" is not matched, but in Rule 2 it matches all the condition including RT_FLOW_SESSION_DENY

Only difference between two rules are I used OR condition in the second part of RULE 1

Rule 1

filter:
 - and:
   - term:
        srx-rt-flow: "RT_FLOW_SESSION_DENY"
   - term:
        srx-policy-name: "default-deny"

filter:
  - or:
   - not:
       terms:
         srx-source-zone-name: ["Internet", "EXTERNAL", "Safe-Zone"]
   - not:
       terms:
         srx-source-address:   ["10.18.109.59", "10.10.10.10", "20.20.20.20", "30.30.30.30"]

Rule 2


filter:
 - and:
   - term:
        srx-rt-flow: "RT_FLOW_SESSION_DENY"
   - term:
        srx-policy-name: "default-deny"

 filter:
 - and:
   - not:
       terms:
         srx-source-zone-name: ["Internet", "EXTERNAL", "Safe-Zone"]
   - not:
       terms:
         srx-source-address:   ["10.18.109.59", "10.10.10.10", "20.20.20.20", "30.30.30.30"]

sathishdsgithub avatar Jul 12 '17 14:07 sathishdsgithub

@Qmando Correct me if I'm wrong the below condition means it should match both the term field (value, something) because of the embedded AND ?

filter:
    - and:
        - not:
            term:
              field: "value"
        - not:
            term:
              _type: "something"

sathishdsgithub avatar Jul 12 '17 14:07 sathishdsgithub

The AND is redundant. Everything under filter is implicitly joined with an AND

filter:
    - and:
        - not:
            term:
              field: "value"
        - not:
            term:
              _type: "something"

is exactly the same as

filter:
    - not:
         term:
           field: "value"
    - not:
         term:
           _type: "something"

Qmando avatar Jul 12 '17 18:07 Qmando

above the filter which rule type to do use ????

cssharavanan avatar May 21 '18 08:05 cssharavanan

@cssharavanan

filters apply to every rule type.

Qmando avatar May 21 '18 17:05 Qmando