本文整理匯總了Python中elastalert.elastalert.ElastAlerter.rules[0]['type']方法的典型用法代碼示例。如果您正苦於以下問題:Python ElastAlerter.rules[0]['type']方法的具體用法?Python ElastAlerter.rules[0]['type']怎麽用?Python ElastAlerter.rules[0]['type']使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類elastalert.elastalert.ElastAlerter
的用法示例。
在下文中一共展示了ElastAlerter.rules[0]['type']方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ea
# 需要導入模塊: from elastalert.elastalert import ElastAlerter [as 別名]
# 或者: from elastalert.elastalert.ElastAlerter import rules[0]['type'] [as 別名]
def ea():
rules = [{'es_host': '',
'es_port': '',
'name': 'anytest',
'index': 'idx',
'filter': [],
'include': ['@timestamp'],
'aggregation': datetime.timedelta(0),
'realert': datetime.timedelta(0),
'processed_hits': {},
'timestamp_field': '@timestamp',
'match_enhancements': []}]
conf = {'rules_folder': 'rules',
'run_every': datetime.timedelta(minutes=10),
'buffer_time': datetime.timedelta(minutes=5),
'alert_time_limit': datetime.timedelta(hours=24),
'es_host': 'es',
'es_port': 14900,
'writeback_index': 'wb',
'rules': rules,
'max_query_size': 100000,
'old_query_limit': datetime.timedelta(weeks=1)}
elasticsearch.client.Elasticsearch = mock_es_client
with mock.patch('elastalert.elastalert.get_rule_hashes'):
with mock.patch('elastalert.elastalert.load_rules') as load_conf:
load_conf.return_value = conf
ea = ElastAlerter(['--pin_rules'])
ea.rules[0]['type'] = mock_ruletype()
ea.rules[0]['alert'] = [mock_alert()]
ea.writeback_es = mock_es_client()
ea.writeback_es.search.return_value = {'hits': {'hits': []}}
ea.writeback_es.create.return_value = {'_id': 'ABCD'}
ea.current_es = mock_es_client('', '')
return ea