elastalert icon indicating copy to clipboard operation
elastalert copied to clipboard

summary_table_fields ignored when aggregation is used

Open ghost opened this issue 9 years ago • 2 comments

Hi,

I need to have a report printed on my alert for the following rule:

name: 'not 200 ok'

type: frequency

num_events: 3

timeframe:
  minutes: 5

use_strftime_index: true
index: logstash-httpd-access-%Y.%m.%d

doc_type: httpd-access

filter:
- term:
    fields.ssl_client_verify.keyword: "SUCCESS"
- term:
    fields.method.keyword: "POST"
- terms:
    fields.url_path.keyword: ["/first/path", "/second/path"]
- terms:
    fields.host_canonical.keyword: ["first_host", "second_host"]
- query:
   query_string:
      query: "NOT fields.http_status:200"

raw_count_keys: False
summary_table_fields:
    - sys.id
    - fields.url_path
    - fields.http_status

alert:
    - email

email:
    - [email protected]

alert_subject: "PROBLEM!!!"

This works. but if I modify it in the following way (notice the aggregation), the report is not printed on the alarm:

name: 'not 200 ok'

type: frequency

num_events: 3

timeframe:
    minutes: 5

use_strftime_index: true
index: logstash-httpd-access-%Y.%m.%d

doc_type: httpd-access

filter:
- term:
    fields.ssl_client_verify.keyword: "SUCCESS"
- term:
    fields.method.keyword: "POST"
- terms:
    fields.url_path.keyword: ["/first/path", "/second/path"]
- terms:
    fields.host_canonical.keyword: ["first_host", "second_host"]
- query:
   query_string:
      query: "NOT fields.http_status:200"

aggregation:
  minutes: 5

raw_count_keys: False
summary_table_fields:
    - sys.id
    - fields.url_path
    - fields.http_status

alert:
    - email

email:
    - [email protected]

alert_subject: "PROBLEM!!!"

Any suggestions? Bug?

ghost avatar Aug 09 '17 16:08 ghost

@amraam83

If you see any alerts less than five minutes it won't trigger, you have to wait for 5 minutes to get the alerts. I see that you have set the time frame: and aggregation: to five minutes. Even if you get any alerts in less than five minutes you have to wait for the aggregation time to complete to get the consolidated alerts.

aggregation: This option allows you to aggregate multiple matches together into one alert. Every time a match is found, ElastAlert will wait for the aggregation period and send all of the matches that have occurred in that time for a particular rule together

You can monitor the alerts using below command. Hope this helps !!!

python -m elastalert.elastalert --start NOW --verbose --rule rule_name.yaml

sathishdsgithub avatar Aug 10 '17 11:08 sathishdsgithub

Add --verbose to the command if you have not already. You'll see lines like "New aggregation for ... next alert at <5 minutes from now>" and "Adding alert for ... for aggregation ID: xxxx"

If you want until that "next alert time" passes, it will send them

Qmando avatar Aug 10 '17 21:08 Qmando