Skip to content

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

alifiroozi80
Copy link

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.

@alifiroozi80
Copy link
Author

Hey @hatamiarash7
This is just a reminder.

Copy link
Owner

@hatamiarash7 hatamiarash7 left a 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()
Copy link
Author

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 {
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants