-
Notifications
You must be signed in to change notification settings - Fork 1
feat(alerts): telegram drop rules #168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Hey @hatamiarash7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These drop rules should match with alert parts like ShortName
, DisplayName
, etc.
params := url.Values{} | ||
params.Add("chat_id", t.Chat) | ||
params.Add("parse_mode", "markdownv2") | ||
if t.Topic != "" { | ||
params.Add("message_thread_id", t.Topic) | ||
} | ||
url := r.config.Notifier.Telegram.Host + r.config.Notifier.Telegram.Token + "/sendMessage?" + params.Encode() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable url
collides with imported package name, that's why I changed it to u
@@ -43,8 +60,12 @@ func (r *Repository) CreateTelegramMessage(alert models.Alert) error { | |||
return err | |||
} | |||
|
|||
for _, url := range urls { | |||
r.CallTelegram(url, body) | |||
for _, u := range urls { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable url
collides with imported package name, that's why I changed it to u
Hello @hatamiarash7
This PR gets an optional
Drop
entry filed as a[]string
, and when the app wants to send alerts in Telegram channels, it first checks the slice, and if the alert matches with any item inside that slice, it simply drops it.