elastalert icon indicating copy to clipboard operation
elastalert copied to clipboard

Giving MISSING VALUE when using command alert with Flatline rule

Open mayank023 opened this issue 7 years ago • 2 comments

I have tried given below rule file wilt slack alert I was able to get alert with proper values when changed alert from slack to command I'm getting MISSING VALUE for the arguments passing in New relic script.

Rulefile.

######################################################################
#  Alert if service 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: 1
# The time period that must contain less than threshold events
#timeframe:
#  hours: 24
timeframe:
  minutes: 2
# 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: "Service.keyword"
# The _type of document to search for (see the value of the "_type" field within Kibana)
doc_type: "_doc"
# 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: "*"
realert:
  minutes: 5
# 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=service:%(Service)s,environment:%(Environment)s,last_run:%(Start Time)s"]

Error Log

image

Any idea?

mayank023 avatar Sep 30 '19 07:09 mayank023

any idea on how can I get values of service, environment and start time in command alert, I have done google and tried changing the value for use_terms_query as false and by removing it but got the same result.

mayank023 avatar Oct 03 '19 07:10 mayank023

Your alert is firing when 0 matches have been found (less than 1) so you can't use fields from a match that you don't have.

NickHeap2 avatar Nov 07 '19 16:11 NickHeap2