-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
Alerting: Enable sending notifications to a specific topic on Telegram #79546
Alerting: Enable sending notifications to a specific topic on Telegram #79546
Conversation
Hi @th0th! I appreciate your contribution! However, currently, we do not accept any changes to the integrations that do not exist in the Prometheus Alertmanager (see https://prometheus.io/docs/alerting/latest/configuration/#telegram_config) because we are trying to unify the Grafana and Prometheus Alertmanagers.
Also, there is another PR that adds a similar field #79534. I left the same message there. |
I think you sent this to the wrong account... |
Hey @yuri-tceretian, thanks for the explanation. I created these 3 PRs:
I didn't quite understand how all these are connected to each other, is there is a way I can run this implementation on my local machine, please tell me and I will test :) Also, let me know if there are additional changes needed 💐 |
Oh, sorry :) |
To test it locally, you need to update Grafana to use your branch in the alerting repository. Replace the import to the local copy. Add this line to the go.mod of Grafana repo.
change path to point to the directory where the alerting repository is cloned. Make sure you do not commit it. |
Thank you, do I need to do the same thing about |
you can replace that "replace" with your version. |
I replaced the
|
@yuri-tceretian I fixed stuff you mentioned. Can you please have another look? |
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.
I merged PR in alerting repository. So, now you can execute
go get github.com/grafana/alerting@ec2c02267fa591e7252ddb44143555bc941ce6fa
and commit those changes into your PR. Unfortunately, your PR seems to be blocked by PR #81512 because alerting module contains some changes that have not updated in Grafana. Let's wait for that PR merged first.
@@ -200,7 +200,7 @@ func (tn *TelegramNotifier) generateTelegramCmd(message string, messageField str | |||
return nil, err | |||
} | |||
|
|||
tn.log.Info("Sending telegram notification", "chat_id", tn.ChatID, "bot_token", tn.BotToken, "apiAction", apiAction) | |||
tn.log.Info("Sending telegram notification", "chat_id", tn.ChatID, "bot_token", tn.BotToken, "message_thread_id", tn.MessageThreadId, "apiAction", apiAction) |
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.
this one can be removed too.
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.
LGTM
Thank you @yuri-tceretian 💐 |
#79546) Co-authored-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
The attribute is `message_thread_id`, according to grafana/grafana#79546
* Add message_thread_id for Telegram contact points * Update resource_alerting_contact_point_notifiers.go * Fix casing and tests The attribute is `message_thread_id`, according to grafana/grafana#79546 * Try with an integer --------- Co-authored-by: Julien Duchesne <julien.duchesne@grafana.com>
I need help, please check the Special notes for your reviewer section.
What is this feature?
Telegram has a feature called group topics, which is like a channel in Slack or Discord. Current Telegram alerting mechanism doesn't allow sending notifications to a specific topic. This PR aims to add (optionally) setting the topic for Telegram type contact point.
Why do we need this feature?
It is very common for Telegram bot integrations to set a custom topic for the messages sent. For example, a group can have multiple topics like #general #notifications, and the user might want to send alerts to the #notifications topic.
Who is this feature for?
For the folks who use Grafana with Telegram alerts.
Special notes for your reviewer:
I added the required changes for the feature, however, I couldn't get it working, so I need a fresh pair of eyes :) It is like some of the changes I made on my development environment are not taken into consideration. For example, I tried replacing all the
api.telegram.org
s in the code with a random, invalid URL, but the "Test" button on the "Contact points" still successfully sent the message to Telegram.Once we get the thing working, I am planning to update relevant part of the docs as well 👍
Please check that: