Elastalert: filters "- not" not working
When I try to use - not filter in Elastalert I get a:
"elastalert_error - {'message': "Error running query: TransportError(400, u'parsing_exception', u'no [query] registered for [not]')""
filter that i am using filter:
- term: field: "string"
- term: field: "string"
- not: wildcard: field: "string*"
any help would be greatly appreciated.
I tried using query_string but i was not able to use a NOT statement successfully
You need to use a query_string if you are using Elasticsearch 5.
What did you try that did not work?
- query:
query_string:
query: "field:string AND field:string NOT field:string*"
- query:
query_string:
query: "NOT field:string*"
- query:
query_string:
query: "!field:string*"
- query:
query_string:
query: "-field:string*"
Try
field:string AND field:string AND NOT field:string*
For some reason this query searches everything except field:string AND field:string AND NOT field:string*
So i used '' before '"' and it worked as expected. Thank you.
P.S. will there ever be a time when you will introduce must_not? at this point when must_not used it, the query that it generated is wrong.
Thanks Again.
Yeah, I'd like to add that at some point soon.
@Mokatsu @Qmando
I'm trying to ignore specific string in field srx-source-zone. 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:corporate. Please assist me ?
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:corporate"
@Mokatsu @Qmando
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.
I believe in Elasticsearch 5.x not filters no longer work. You have to use query_string