Skip to content

Commit

Permalink
add lark alerter to schema and loaders
Browse files Browse the repository at this point in the history
  • Loading branch information
seanyinx committed Oct 7, 2023
1 parent b08db8f commit 304041e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/source/elastalert.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions elastalert/alerters/lark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions elastalert/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions elastalert/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down

0 comments on commit 304041e

Please sign in to comment.