elastalert icon indicating copy to clipboard operation
elastalert copied to clipboard

ElastAlert Querying latest indices name

Open sathishdsgithub opened this issue 8 years ago • 7 comments

@Qmando @Dmitry1987

How to query the latest indices name from elastisearch database.

I have my indices name in the format of firewalls_random-number (example firewalls_2514 ). Since my indices name does not contain year and month I'm not able to query the latest indices. Somehow I have to make the elastalert to query the latest indices. If I give firewall_* it takes huge time to query all the indices

Below screenshot for reference. Please assist

image

sathishdsgithub avatar Jan 18 '18 12:01 sathishdsgithub

Hi, I think it knows which indexes to search depends on your specified time, you don't need to put specific index names. I use "graylog_*" on my 12TB data, and it's totally fine (I have 6 ES nodes, medium size, 4 cpu/16 ram each).

Not sure if there's any existing option in ElastAlert for this.. you'll probably need to dynamically rewrite your rule text each time before it runs ...

Dmitry1987 avatar Jan 18 '18 16:01 Dmitry1987

@Dmitry1987 I use --start NOW and its querying all the indices with name firewalls_. Is there any option to query the latest created indices in ES node?. I don't want elastalert to query all the firewall_, I just want the latest one to be queried . Between,what vaLue you set for run_every in config.yaml?

sathishdsgithub avatar Jan 18 '18 17:01 sathishdsgithub

I run every 20 minutes, and have 15 rules approximately.

the --start and --end can be used with exact timestamp in ISO format I think... or the format of your elasticsearch logs

Dmitry1987 avatar Jan 18 '18 17:01 Dmitry1987

@Dmitry1987 Can you share some example of --start and --end time format ? If possible share me the command that you use to start elastalert

sathishdsgithub avatar Jan 18 '18 17:01 sathishdsgithub

something like python elastalert/elastalert.py --start "2017-06-19 10:00" --es_debug_trace debug.log I use --start only when testing a rule, but on a usual run it always looks for the time marked in its index in elasticsearch (you have an index where it saves its findings after every rule run, to realert only after enough time passed, so depends on "last run" it will calculate how long back to query this time)

Dmitry1987 avatar Jan 18 '18 17:01 Dmitry1987

@Dmitry1987 thanks ... So what command you exactly use to run elastalert for production?

sathishdsgithub avatar Jan 18 '18 17:01 sathishdsgithub

There's no functionality to find the "most recent" index right now.

Using "firewall_*" should work since everything is timestamped, though it might be significantly slower. At least, older versions of Elasticsearch are still slower despite the filter on @timestamp. I'm actually impressed there isn't a performance hit to using * on indexes with 12TB.

Qmando avatar Jan 18 '18 19:01 Qmando