本文整理匯總了Python中elastalert.ruletypes.FrequencyRule.add_count_data方法的典型用法代碼示例。如果您正苦於以下問題:Python FrequencyRule.add_count_data方法的具體用法?Python FrequencyRule.add_count_data怎麽用?Python FrequencyRule.add_count_data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類elastalert.ruletypes.FrequencyRule
的用法示例。
在下文中一共展示了FrequencyRule.add_count_data方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_freq_count
# 需要導入模塊: from elastalert.ruletypes import FrequencyRule [as 別名]
# 或者: from elastalert.ruletypes.FrequencyRule import add_count_data [as 別名]
def test_freq_count():
rules = {'num_events': 100,
'timeframe': datetime.timedelta(hours=1),
'use_count_query': True}
# Normal match
rule = FrequencyRule(rules)
rule.add_count_data({ts_to_dt('2014-10-10T00:00:00'): 75})
assert len(rule.matches) == 0
rule.add_count_data({ts_to_dt('2014-10-10T00:15:00'): 10})
assert len(rule.matches) == 0
rule.add_count_data({ts_to_dt('2014-10-10T00:25:00'): 10})
assert len(rule.matches) == 0
rule.add_count_data({ts_to_dt('2014-10-10T00:45:00'): 6})
assert len(rule.matches) == 1
# First data goes out of timeframe first
rule = FrequencyRule(rules)
rule.add_count_data({ts_to_dt('2014-10-10T00:00:00'): 75})
assert len(rule.matches) == 0
rule.add_count_data({ts_to_dt('2014-10-10T00:45:00'): 10})
assert len(rule.matches) == 0
rule.add_count_data({ts_to_dt('2014-10-10T00:55:00'): 10})
assert len(rule.matches) == 0
rule.add_count_data({ts_to_dt('2014-10-10T01:05:00'): 6})
assert len(rule.matches) == 0
rule.add_count_data({ts_to_dt('2014-10-10T01:00:00'): 75})
assert len(rule.matches) == 1