当前位置: 首页>>代码示例>>Python>>正文


Python ElastAlerter.rules[0]["type"]方法代码示例

本文整理汇总了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": [],
            "not_filter": [],
            "include": ["@timestamp"],
            "aggregation": datetime.timedelta(0),
            "realert": datetime.timedelta(0),
            "processed_hits": {},
            "timestamp_field": "@timestamp",
            "match_enhancements": [],
            "rule_file": "blah.yaml",
            "ts_to_dt": ts_to_dt,
            "dt_to_ts": dt_to_ts,
            "_source_enabled": True,
        }
    ]
    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),
        "disable_rules_on_error": False,
    }
    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
开发者ID:avanishp,项目名称:elastalert,代码行数:48,代码来源:conftest.py


注:本文中的elastalert.elastalert.ElastAlerter.rules[0]["type"]方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。