I have a watcher that checks for specific logfile entries and I need its action to trigger exactly once for any entries found within a specific timeframe. It currently checks for logfile entries once a minute using the following range:
"range": {
"@timestamp": {
"gte": "{{ ctx.trigger.scheduled_time }}||-1m",
"lte": "{{ ctx.trigger.scheduled_time }}"
}
}
Due to network delays and such it often happens that a logfile entry with a timestamp from an interval gets indexed only after that interval's watcher has already run, especially if the logfile entry was written to the file a few millis before the watcher triggered and logstash hasn't processed it yet. Subsequent watcher queries will therefore not find this logfile entry since it's in the previous interval. E.g.
- Watcher checks for timestamps in the range 00:00:00 - 00:01:00 and finds no entries
- A logfile entry with a timestamp of 00:00:59 gets indexed by logstash
- Watcher checks for timestamps in the range 00:01:00 - 00:02:00 and finds no entries
There are a few suboptimal ways to deal with this:
- Increase the range to two minutes into the past. Logfile entries then often trigger the watcher's action twice.
- Have the watcher run less often, e.g. every 5 minutes. Boundary issues are less probable but still do happen.
I had the idea of going with the first option and tagging already processed logfile entries. Alas, there's no update action, only an index action. Is there a simple solution that doesn't involve webhooks back to Elastic?
