not getting hit in Flatline Rule
Here is my service pushing data to elastic search instance, I want to use elastalert to alert me for scenario when application does not push data for 24 hours
Rule file
######################################################################
# Alert if offering team has not run the tool in the last 24 hours #
######################################################################
# (Required)
# Rule name, must be unique
name: last-execution-check
# (Required)
# Type of alert
type: flatline
# (Required)
# Index to search, wildcard supported
index: query-tracking-*
# All documents must have a timestamp field.
# ElastAlert will try to use @timestamp by default, but this can be changed with the timestamp_field option
timestamp_field: "End Time"
# The minimum number of events for an alert not to be triggered
threshold: 2
# The time period that must contain less than threshold events
timeframe:
hours: 24
#timeframe:
# minutes: 30
# With flatline rule, query_key means that an alert will be triggered if any value of query_key has been seen at least once and then falls below the threshold.
#query_key: "Offering.keyword"
query_key: "offering_id.keyword"
# The _type of document to search for (see the value of the "_type" field within Kibana)
doc_type: "report"
# ElastAlert will make an aggregation query against Elasticsearch to get counts of documents matching each unique value of query_key
use_terms_query: true
# (Required)
# A list of Elasticsearch filters used for find events
# These filters are joined with AND and nested in a filtered query
# For more info: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html
filter:
- query_string:
query: "*"
alert_text: "Offering team {0} have not run the datacollector tool in the last 24 hours"
alert_text_args: ["key"]
# (Required)
# The alert is use when a match is found
alert:
- command
command: ["scripts/post_new_relic.sh", "--event_type=last_execution_check", "--key_value_list=offering:%(Offering)s,last_run:%(Start Time)s"]
But here I'm not getting hit even when there is no logs pushed to elastic search instance during that time. Within the timeframe, query_key get at least one occurrence and then rule is stopping before timeframe ends.
rule test command is stopping with out any hit. I believe rule test should be running continuously.
elastalert-test-rule --config config/config.yaml rules/flatline.yaml
INFO:elastalert:Note: In debug mode, alerts will be logged to console but NOT actually sent.
To send them but remain verbose, use --verbose instead.
Didn't get any results.
INFO:elastalert:Note: In debug mode, alerts will be logged to console but NOT actually sent.
To send them but remain verbose, use --verbose instead.
1 rules loaded
INFO:apscheduler.scheduler:Adding job tentatively -- it will be properly scheduled when the scheduler starts
INFO:elastalert:Queried rule last-execution-check from 2019-09-11 15:20 IST to 2019-09-11 15:21 IST: 0 buckets
INFO:elastalert:Queried rule last-execution-check from 2019-09-11 15:21 IST to 2019-09-11 15:22 IST: 0 buckets
INFO:elastalert:Queried rule last-execution-check from 2019-09-11 15:22 IST to 2019-09-11 15:22 IST: 0 buckets
Would have written the following documents to writeback index (default is elastalert_status):
elastalert_status - {'rule_name': 'last-execution-check', 'endtime': datetime.datetime(2019, 9, 11, 9, 52, 36, 739687, tzinfo=tzutc()), 'starttime': datetime.datetime(2019, 9, 11, 9, 50, 35, 539687, tzinfo=tzutc()), 'matches': 0, 'hits': 0, '@timestamp': datetime.datetime(2019, 9, 11, 9, 52, 39, 929321, tzinfo=tzutc()), 'time_taken': 1.8398380279541016}
Please show the full JSON of a document you expected to match
Try running python -m elastalert.elastalert --config config/config.yaml --rule flatline.yaml --debug --start 2019-09-10 --end 2019-09-11 for better info
@Qmando i have tried this and found
python -m elastalert.elastalert --config config/config.yaml --rule rules/flatline.yaml --debug --start 2019-09-16 --end 2019-09-17
/root/sre/git/main/datacollector/cloud-platform-data-monitor/venv/lib/python2.7/site-packages/elastalert/config.py:31: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
rule_schema = jsonschema.Draft4Validator(yaml.load(open(os.path.join(os.path.dirname(__file__), 'schema.yaml'))))
INFO:elastalert:Note: In debug mode, alerts will be logged to console but NOT actually sent.
To send them but remain verbose, use --verbose instead.
INFO:elastalert:Starting up
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 17:00 PDT to 2019-09-15 17:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 17:15 PDT to 2019-09-15 17:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 17:30 PDT to 2019-09-15 17:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 17:45 PDT to 2019-09-15 18:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 18:00 PDT to 2019-09-15 18:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 18:15 PDT to 2019-09-15 18:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 18:30 PDT to 2019-09-15 18:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 18:45 PDT to 2019-09-15 19:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 19:00 PDT to 2019-09-15 19:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 19:15 PDT to 2019-09-15 19:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 19:30 PDT to 2019-09-15 19:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 19:45 PDT to 2019-09-15 20:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 20:00 PDT to 2019-09-15 20:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 20:15 PDT to 2019-09-15 20:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 20:30 PDT to 2019-09-15 20:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 20:45 PDT to 2019-09-15 21:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 21:00 PDT to 2019-09-15 21:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 21:15 PDT to 2019-09-15 21:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 21:30 PDT to 2019-09-15 21:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 21:45 PDT to 2019-09-15 22:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 22:00 PDT to 2019-09-15 22:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 22:15 PDT to 2019-09-15 22:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 22:30 PDT to 2019-09-15 22:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 22:45 PDT to 2019-09-15 23:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 23:00 PDT to 2019-09-15 23:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 23:15 PDT to 2019-09-15 23:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 23:30 PDT to 2019-09-15 23:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-15 23:45 PDT to 2019-09-16 00:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 00:00 PDT to 2019-09-16 00:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 00:15 PDT to 2019-09-16 00:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 00:30 PDT to 2019-09-16 00:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 00:45 PDT to 2019-09-16 01:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 01:00 PDT to 2019-09-16 01:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 01:15 PDT to 2019-09-16 01:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 01:30 PDT to 2019-09-16 01:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 01:45 PDT to 2019-09-16 02:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 02:00 PDT to 2019-09-16 02:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 02:15 PDT to 2019-09-16 02:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 02:30 PDT to 2019-09-16 02:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 02:45 PDT to 2019-09-16 03:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 03:00 PDT to 2019-09-16 03:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 03:15 PDT to 2019-09-16 03:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 03:30 PDT to 2019-09-16 03:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 03:45 PDT to 2019-09-16 04:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 04:00 PDT to 2019-09-16 04:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 04:15 PDT to 2019-09-16 04:30 PDT: 1 / 1 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 04:30 PDT to 2019-09-16 04:45 PDT: 1 / 1 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 04:45 PDT to 2019-09-16 05:00 PDT: 2 / 2 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 05:00 PDT to 2019-09-16 05:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 05:15 PDT to 2019-09-16 05:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 05:30 PDT to 2019-09-16 05:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 05:45 PDT to 2019-09-16 06:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 06:00 PDT to 2019-09-16 06:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 06:15 PDT to 2019-09-16 06:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 06:30 PDT to 2019-09-16 06:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 06:45 PDT to 2019-09-16 07:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 07:00 PDT to 2019-09-16 07:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 07:15 PDT to 2019-09-16 07:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 07:30 PDT to 2019-09-16 07:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 07:45 PDT to 2019-09-16 08:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 08:00 PDT to 2019-09-16 08:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 08:15 PDT to 2019-09-16 08:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 08:30 PDT to 2019-09-16 08:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 08:45 PDT to 2019-09-16 09:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 09:00 PDT to 2019-09-16 09:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 09:15 PDT to 2019-09-16 09:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 09:30 PDT to 2019-09-16 09:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 09:45 PDT to 2019-09-16 10:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 10:00 PDT to 2019-09-16 10:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 10:15 PDT to 2019-09-16 10:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 10:30 PDT to 2019-09-16 10:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 10:45 PDT to 2019-09-16 11:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 11:00 PDT to 2019-09-16 11:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 11:15 PDT to 2019-09-16 11:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 11:30 PDT to 2019-09-16 11:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 11:45 PDT to 2019-09-16 12:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 12:00 PDT to 2019-09-16 12:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 12:15 PDT to 2019-09-16 12:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 12:30 PDT to 2019-09-16 12:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 12:45 PDT to 2019-09-16 13:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 13:00 PDT to 2019-09-16 13:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 13:15 PDT to 2019-09-16 13:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 13:30 PDT to 2019-09-16 13:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 13:45 PDT to 2019-09-16 14:00 PDT: 3 / 3 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 14:00 PDT to 2019-09-16 14:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 14:15 PDT to 2019-09-16 14:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 14:30 PDT to 2019-09-16 14:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 14:45 PDT to 2019-09-16 15:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 15:00 PDT to 2019-09-16 15:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 15:15 PDT to 2019-09-16 15:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 15:30 PDT to 2019-09-16 15:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 15:45 PDT to 2019-09-16 16:00 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 16:00 PDT to 2019-09-16 16:15 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 16:15 PDT to 2019-09-16 16:30 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 16:30 PDT to 2019-09-16 16:45 PDT: 0 / 0 hits
INFO:elastalert:Queried rule last-execution-check from 2019-09-16 16:45 PDT to 2019-09-16 17:00 PDT: 0 / 0 hits
INFO:elastalert:Skipping writing to ES: {'hits': 7, 'matches': 0, '@timestamp': '2019-09-17T07:52:56.349472Z', 'rule_name': 'last-execution-check', 'starttime': '2019-09-16T00:00:00Z', 'endtime': '2019-09-17T00:00:00Z', 'time_taken': 26.71217918395996}
INFO:elastalert:Ran last-execution-check from 2019-09-15 17:00 PDT to 2019-09-16 17:00 PDT: 7 query hits (0 already seen), 0 matches, 0 alerts sent
I got it working as I want but land up with another issue defined here