Skip to content

Commit

Permalink
Merge pull request #4 from BigDataBoutique/fix-cron-starttime
Browse files Browse the repository at this point in the history
fixing start time for cron_schedule rules
shaigbdb authored Apr 5, 2021
2 parents 8ae62a1 + 689429d commit 588bacf
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -334,6 +334,9 @@ minute (0-59), hour (0-23), day of month (1-31), month (1-12), day of week (MON-

Fields are separated by space, values separated by comma, * for all values

notice that cron_schedule is currently only supported for use_count_query uses.


### Questions? Drop by #elastalert on Freenode IRC.
### BDB enhancements Questions? Contact us at info@bigdataboutique.com

13 changes: 8 additions & 5 deletions elastalert/elastalert.py
Original file line number Diff line number Diff line change
@@ -721,7 +721,7 @@ def set_starttime(self, rule, endtime):

# Use buffer for normal queries, or run_every increments otherwise
# or, if scan_entire_timeframe, use timeframe

#TODO handle cron interval for non "use_count_query" case
if not rule.get('use_count_query') and not rule.get('use_terms_query'):
if not rule.get('scan_entire_timeframe'):
buffer_time = rule.get('buffer_time', self.buffer_time)
@@ -741,11 +741,14 @@ def set_starttime(self, rule, endtime):
self.adjust_start_time_for_interval_sync(rule, endtime)

else:
if not rule.get('scan_entire_timeframe'):
# Query from the end of the last run, if it exists, otherwise a run_every sized window
rule['starttime'] = rule.get('previous_endtime', endtime - self.run_every)
if not rule.get('cron_schedule'):
if not rule.get('scan_entire_timeframe'):
# Query from the end of the last run, if it exists, otherwise a run_every sized window
rule['starttime'] = rule.get('previous_endtime', endtime - self.run_every)
else:
rule['starttime'] = rule.get('previous_endtime', endtime - rule['timeframe'])
else:
rule['starttime'] = rule.get('previous_endtime', endtime - rule['timeframe'])
rule['starttime'] = endtime - rule['timeframe']

def adjust_start_time_for_overlapping_agg_query(self, rule):
if rule.get('aggregation_query_element'):

0 comments on commit 588bacf

Please sign in to comment.