當前位置: 首頁>>代碼示例>>Python>>正文


Python ElastAlerter.rules[0]["alert"]方法代碼示例

本文整理匯總了Python中elastalert.elastalert.ElastAlerter.rules[0]["alert"]方法的典型用法代碼示例。如果您正苦於以下問題:Python ElastAlerter.rules[0]["alert"]方法的具體用法?Python ElastAlerter.rules[0]["alert"]怎麽用?Python ElastAlerter.rules[0]["alert"]使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在elastalert.elastalert.ElastAlerter的用法示例。


在下文中一共展示了ElastAlerter.rules[0]["alert"]方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: ea

# 需要導入模塊: from elastalert.elastalert import ElastAlerter [as 別名]
# 或者: from elastalert.elastalert.ElastAlerter import rules[0]["alert"] [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]["alert"]方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。