Closed polshe-v closed 9 months ago
Thanks for this enhancement. The PR looks good. Can you confirm that alerts show up properly in Telegram when telegram_thread_id
is not provided (default behavior)?
Yes, it works as usual
I performed following tests:
telegram_thread_id
option in a rule. Result: works as usual, alert is sent to the group chat.telegram_thread_id
option in a rule. Result: alert is sent to general thread of supergroup.telegram_thread_id: 2
in a rule. Result: not working, because common group chat obviously has no threads. Writes an error like this: ERROR:elastalert:Error while running alert telegram: Error posting to Telegram: 400 Client Error: Bad Request for url: https://api.telegram.org/bot<BOT_TOKEN>/sendMessage. Details: {"ok":false,"error_code":400,"description":"Bad Request: message thread not found"}
telegram_thread_id: 2
in a rule. Result: alert is sent to thread with ID 2.Thank you for confirming.
Description
I wanted to sort alerts sent to Telegram, because I have different log sources and there are so many types of them, therefore so many chats. But having multiple Telegram chats for every source type is not convenient (chaotic chats order, difficult managing
telegram_room_id
in rules).Now Telegram has a feature of supergroups/forums where you can create threads. Using this supergroup/forum I can have all my alerts in 1 chat and sort them in threads. So I decided to add an option for
message_thread_id
of Telegram sendMessage function.Checklist
make test-docker
with my changes.Questions or Comments