Whitelists doesn't seems to work
Here is my rule:
name: Security - Apache Access events frequency
type: frequency
index: logstash-access-apache
num_events: 600
timeframe:
minutes: 1
alert:
- hipchat
use_terms_query: true
doc_type: apache_access
query_key: clientip.raw
fields:
- clientip.raw
- geoip.country_name
top_count_keys:
- beat.hostname
- app
- request
compare_key: clientip.raw
whitelist: ["1.2.3.4", "5.6.7.8"]
hipchat_auth_token: XXX
hipchat_room_id: XXX
Logs with the IPs 1.2.3.4 and 5.6.7.8 are triggered as well, and as I understood, it should not work like that.
whitelist as a config option only works with type: whitelist. You can achieve this same affect by adding
filter:
- not:
terms:
clientip.raw: ["1.2.3.4", "5.6.7.8"]
@Qmando thanks for your reply. I've tried that already with no success. Stressing from the IP 1.2.3.4 triggers the alert.
Any idea why?
The filter did not affect the results at all? That seems surprising to me. I've tested a very similar set up to confirm this. When using use_terms_query + somefield.raw as the query_key, adding that filter filtered out the results as I expected.
What version of Elasticsearch are you using? I tested it using < 2.0 and it's possible aggregation filters are not working. Can you verify that you would get no results if you add a garbage filter like
filter:
- term:
clientip.raw: "dlfghkjdfhgdjfkhg"
which should give 0 results at all.
Thanks, it worked.
@arall @Qmando
I'm using the below rule to whitelist few IP address and its working as expected. How do I achieve the same for subnet range/IP address range example /24, /16, OR 192.168.1.1-192.168.1.100 etc ...Not sure, if this can be achieved with ElastAlert?
filter:
- not:
terms:
src_ip: ["10.10.10.10", "20.20.20.20", "30.30.30.30"]
Use these https://www.elastic.co/guide/en/elasticsearch/reference/2.4/query-dsl-query-string-query.html#_regular_expressions in a filter plus type: any
@Qmando
-
Can we use whitelist by setting the type as any ?
type: any -
Is it possible to mention two fields in compare_key ?
example: compare_key: [src_ip, dst_ip] ?
-
I just told you you can use
type: anywith a filter to achieve the same effect. http://elastalert.readthedocs.io/en/latest/ruletypes.html#any -
http://elastalert.readthedocs.io/en/latest/ruletypes.html?highlight=compare_key#change
compare_key: The names of the field to monitor for changes. Since this is list of strings, we can have multiple keys. An alert will trigger if any of the fields change.
@Qmando Thanks, I tried different options to achieve whitelist but it's not working.
I'm trying to achieve the below working rule with whitelist but it's not matching.
Working rule with term condition
filter:
- not:
terms:
srx-source-zone-name: ["EXTERNAL"]
My whitelist condition which is not working
type: any
compare_key: srx-source-zone-name
ignore_null: true
whitelist:
- "EXTERNAL" ==> tried with "" and without ""
Am I missing something here?
You can't use the whitelist option with type: any. You can use type: any plus filters to achieve that same effect.
type: any
filter:
- not:
terms:
srx-source-zone-name: ["EXTERNAL"]
is equivalent to
type: whitelist
compare_key: srx-source-zone-name
whitelist:
- EXTERNAL
@Qmando
If I understood correctly I cannot use both cardinality type and whitelist in same YAML rule.
Is it possible to create a separate rule with type: whitelist rule 2and the mention my file list(- "!file /tmp/whitelist1.txt" ) and call the rule 2 to my rule 1 ? if possible let me know how to call the rule 2 to my rule 1? will it work?
@Qmando
Can I use something like below?
type: cardinality filter:
- terms: rule_name: rule -- > whitelist rule yaml