スパイクが発生したときに通知するようにアラートを設定したいと考えています。私のデータは次のように構成されています。
"_source": {
"@timestamp": 2016-11-23T18:30:45.233Z,
"invalid_request": 400,
"total_request": 40000
}
無効なリクエストの比率が 20 分間にわたって急増した場合にメールを送信するスパイク アラートを設定したいのですが、次のルール yaml ではヒットしません。
# (Required)
# Rule name, must be unique
name: Invlid Count Spike
# (Required)
# Type of alert.
# (Required)
# Index to search, wildcard supported
index: logstash-*
# (Required one of _cur or _ref, spike specific)
# The minimum number of events that will trigger an alert
threshold_cur: 1
#threshold_ref: 5
# The size of the window used to determine average event frequency
# We use two sliding windows each of size timeframe
# To measure the 'reference' rate and the current rate
timeframe:
minutes: 20
# (Required, spike specific)
# The spike rule matches when the current window contains spike_height times more
# events than the reference window
spike_height: 2
# (Required, spike specific)
# The direction of the spike
# 'up' matches only spikes, 'down' matches only troughs
# 'both' matches both spikes and troughs
spike_type: "both"
# (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/c
urrent/query-dsl.html
script_fields:
invalid_ratio:
script:
doc['invalid_request'].value / doc['total_request'].value
filter:
- range:
invalid_ratio:
gt: 0
# (Required)
# The alert is use when a match is found
alert:
- "email"
# (required, email specific)
# a list of email addresses to send alerts to
email:
- "john.doe@email.com"
単純なクエリ (total_request が 0 より大きい場合のトリガーなど) を入力するだけでメールが送信されるため、メール送信が正常に機能していることはわかっていますが、入力したスクリプトが期待どおりに機能していないようです。elastalarm に精通している人なら誰でも、この問題について大いに役立つでしょう。ありがとう。