From 304041ec152ac07dbbad5523b63954ccf122b592 Mon Sep 17 00:00:00 2001 From: yinxiang Date: Tue, 26 Sep 2023 18:15:58 +0800 Subject: [PATCH] add lark alerter to schema and loaders --- docs/source/elastalert.rst | 1 + elastalert/alerters/lark.py | 4 ++-- elastalert/loaders.py | 2 ++ elastalert/schema.yaml | 3 +++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/source/elastalert.rst b/docs/source/elastalert.rst index ecfdcffb..e989092f 100755 --- a/docs/source/elastalert.rst +++ b/docs/source/elastalert.rst @@ -45,6 +45,7 @@ Currently, we have support built in for these alert types: - HTTP POST - HTTP POST 2 - Jira +- Lark - Line Notify - Mattermost - Microsoft Teams diff --git a/elastalert/alerters/lark.py b/elastalert/alerters/lark.py index 86823775..e74db445 100644 --- a/elastalert/alerters/lark.py +++ b/elastalert/alerters/lark.py @@ -15,7 +15,7 @@ def __init__(self, rule): super(LarkAlerter, self).__init__(rule) self.lark_bot_id = self.rule.get('lark_bot_id', None) self.lark_webhook_url = f'https://open.feishu.cn/open-apis/bot/v2/hook/{self.lark_bot_id}' - self.lark_msgtype = self.rule.get('lark_msgtype', 'text') + self.lark_msg_type = self.rule.get('lark_msgtype', 'text') def alert(self, matches): title = self.create_title(matches) @@ -27,7 +27,7 @@ def alert(self, matches): } payload = { - 'msg_type': self.lark_msgtype, + 'msg_type': self.lark_msg_type, "content": { "title": title, "text": body diff --git a/elastalert/loaders.py b/elastalert/loaders.py index 994beddf..4e0524a5 100644 --- a/elastalert/loaders.py +++ b/elastalert/loaders.py @@ -25,6 +25,7 @@ import elastalert.alerters.googlechat import elastalert.alerters.httppost import elastalert.alerters.httppost2 +import elastalert.alerters.lark import elastalert.alerters.line import elastalert.alerters.pagertree import elastalert.alerters.rocketchat @@ -126,6 +127,7 @@ class RulesLoader(object): 'zabbix': ZabbixAlerter, 'discord': elastalert.alerters.discord.DiscordAlerter, 'dingtalk': elastalert.alerters.dingtalk.DingTalkAlerter, + 'lark': elastalert.alerters.lark.LarkAlerter, 'chatwork': elastalert.alerters.chatwork.ChatworkAlerter, 'datadog': elastalert.alerters.datadog.DatadogAlerter, 'ses': elastalert.alerters.ses.SesAlerter, diff --git a/elastalert/schema.yaml b/elastalert/schema.yaml index b24bfb83..f2b38865 100644 --- a/elastalert/schema.yaml +++ b/elastalert/schema.yaml @@ -536,6 +536,9 @@ properties: jira_transition_to: {type: string} jira_bump_after_inactivity: {type: number} + ### Lark + lark_bot_id: {type: string, enum: ['text']} + ### Line Notify linenotify_access_token: {type: string}