elastalert icon indicating copy to clipboard operation
elastalert copied to clipboard

Understanding flatline and use_terms_query setting

Open Trustys opened this issue 9 years ago • 2 comments

Hello,

My goal is to set up an alert if one syslog device stop to send log.

For my test, I have two machine which send syslog logs on a regular and controlled frequency. To test the rule, I disable the network card of the machine.

I read all of the topics but I can't find a good explication.

config.yaml :


run_every:
  minutes: 1

buffer_time:
  minutes: 45

If I use the setting use_terms_query, it didn't works.

Here is the rule :

index: graylog_*

type: flatline

query_key: event_src

use_terms_query: true

doc_type:  syslog

threshold: 1

timeframe:
  minutes: 3

filter:
- query:
    query_string:
      query: "_exists_:event_src"

Alerts logs ( I never see any query hits )

[...]

2017-04-24 11:40:47,276 DEBG 'elastalert' stderr output: INFO:elastalert:Queried rule # Log Collection alert from 2017-04-24 11:39 CEST to 2017-04-24 11:40 CEST: 0 buckets

2017-04-24 11:40:47,315 DEBG 'elastalert' stderr output: INFO:elastalert:Ran # Log Collection alert from 2017-04-24 11:39 CEST to 2017-04-24 11:40 CEST: 0 query hits, 0 matches, 0 alerts sent

[...]

If I don't use use_terms_query, it works :

index: graylog_*

type: flatline

query_key: event_src

doc_type: syslog

threshold: 1

timeframe: minutes: 3

filter:

  • query: query_string: query: "exists:event_src"

Alert logs : (I see query hits and alert trigger)

[...]

2017-04-24 11:32:05,762 DEBG 'elastalert' stderr output: INFO:elastalert:Queried rule # Log Collection alert from 2017-04-24 11:16 CEST to 2017-04-24 11:31 CEST: 46607 / 6607 hits (scrolling..)

[...]

2017-04-24 11:32:08,083 DEBG 'elastalert' stderr output: INFO:elastalert:Ran # Log Collection alert from 2017-04-24 11:16 CEST to 2017-04-24 11:31 CEST: 46607 query hits, 2 matches, 1 alerts sent

I see a main difference :

When use_terms_query is used, we have one minute job : from 2017-04-24 11:39 CEST to 2017-04-24 11:40

When use_terms_query is not used, we have 15 minutes jobs : from 2017-04-24 11:16 CEST to 2017-04-24 11:31 CEST

I would like to understand why it works if I don't use use_terms_query (because it should works with !), and why the time job are not the same (1 minute with use_terms_query and 15 minutes without use_terms_query)

Thanks for your support !

Trustys avatar Apr 24 '17 09:04 Trustys

Can you post JSON of a document? The two things that could potentially go wrong here at that _type is not "syslog" or that "event_src" doesn't actually exist. You can also add --es_debug_trace logfile to log the full queries being made, which may or may not be helpful in debugging.

Qmando avatar Apr 24 '17 17:04 Qmando

You are right ! I used the field "type" (a field in graylog) instead of the field "_type" (from elastic). Problem solved. Thanks for your help ! :-)

Trustys avatar Apr 25 '17 11:04 Trustys