elastalert icon indicating copy to clipboard operation
elastalert copied to clipboard

How to set exclude document not alert ?

Open stefansaye opened this issue 10 years ago • 7 comments

hi ,

I have set a rule as below, it's will alert when program field is vty , but how to set exclude events when program is vty and user value have the keyword "bo"?

name: action rule
type: frequency
index: logstash-*
 num_events: 1
 timeframe:
 hours: 4
filter:
 - term:
 program: "vty"
alert:
  - "email"
email: "my@email"

for example , program is vty , user is abc then alert , if program is vty ,user is bob-an will not alert , if program is vty ,user is abom-bc will not alert , is it possible ? how to set ? Any ideas?

stefansaye avatar Aug 17 '16 15:08 stefansaye

filter:
  - not:
       term:
         program: "vty"
  - not: 
       wildcard:
         user: "*bo*"

You may want to use program.raw and user.raw if they are analyzed fields (they probable are).

Qmando avatar Aug 17 '16 17:08 Qmando

Qmando, my user's mapping is analyzed . I have try to add you filter in my rule. but it's won't send any alert when the program is vty. Any ideas?

stefansaye avatar Aug 18 '16 02:08 stefansaye

Oh, I misread. Just remove the not in front of vtw filte.

filter:
  - term:
       program: "vty"
  - not: 
       wildcard:
         user.raw: "*bo*"

Qmando avatar Aug 18 '16 17:08 Qmando

Qmando , I changed my rule as you said as below , but got the error msg ,

ERROR:root:Error running query: TransportError(400, u'search_phase_execution_exception', u'[not] query does not support [user]'

i try to set that as follows,

filter:
  - term:
       program: "vty"
  - not: 
       wildcard:
         user: ["*bo*" , "*an*","cd","*an*"]

stefansaye avatar Aug 19 '16 03:08 stefansaye

Oops, should be

- not:
     query:
       wildcard:
         user: ....

my bad

Qmando avatar Aug 19 '16 18:08 Qmando

Qmando ,thanks for a lot. work success now.

stefansaye avatar Aug 21 '16 02:08 stefansaye

@Qmando @stefansaye I'm trying to ignore specific string in field srx-source-zone-name. I tried with options whitelist and query_string and filter term nothing worked.

I'm trying to exclude the below filed using NOT in query_string srx-source-zone-name:EXTERNAL. Please assist me ?

srx-rt-flow : RT_FLOW_SESSION_DENY srx-source-address: 10.18.109.59 srx-source-port: 56453 srx-source-zone-name: EXTERNAL

Tried below method but nothing is working. I get matches for the NOT string also :-(

Method 1:

doc_type: message

filter:
- query:
    query_string:
        query: "_type:message"
- query:
     query_string:
        query: "srx-rt-flow:RT_FLOW_SESSION_DENY"
- query:
     query_string:
        query: "NOT srx-source-zone-name:EXTERNAL"

Method 2:

filter:
- query:
    query_string:
        query: "_type:message"
- query:
     query_string:
        query: "srx-rt-flow:RT_FLOW_SESSION_DENY AND NOT srx-source-zone-name:EXTERNAL"


Method 3:

filter:
   - not:
       terms:
          srx-source-zone-name: ["EXTERNAL"]

Method 4:

field: srx-source-zone-name type: any compare_key: srx-source-zone-name ignore_null: true whitelist:

  • "EXTERNAL"

Method 5:

filter:
    - not:
         term:
             srx-source-zone-name: "EXTERNAL"

Am I missing something here ? I did not get any error when I run the rule but the filter is not negating the mentioned string.

sathishdsgithub avatar Jul 12 '17 06:07 sathishdsgithub