alertmanager
alertmanager copied to clipboard
Request: Add topic_id as an optional parameter to telegram_config
What did you do? Configured Alertmanager to use Telegram notifications, and set the chat_id to be a group.
What did you expect to see? The ability to set a topic_id to target a particular topic.
What did you see instead? Under which circumstances? Messages go to first topic, usually General.
Environment
-
System information: Linux 6.1.0-17-amd64 x86_64
-
Alertmanager version: alertmanager, version 0.26.0 (branch: HEAD, revision: d7b4f0c7322e7151d6e3b1e31cbc15361e295d8d) build user: root@df8d7debeef4 build date: 20230824-11:11:58 go version: go1.20.7 platform: linux/amd64 tags: netgo
-
Prometheus version: prometheus, version 2.49.1 (branch: HEAD, revision: 43e14844a33b65e2a396e3944272af8b3a494071) build user: root@6d5f4c649d25 build date: 20240115-16:58:43 go version: go1.21.6 platform: linux/amd64 tags: netgo,builtinassets,stringlabels
-
Alertmanager configuration file:
global:
resolve_timeout: 10m
route:
group_by: ['alertname']
group_wait: 30s
group_interval: 30s
repeat_interval: 5m
receiver: 'id-telegram'
receivers:
- name: 'id-telegram'
telegram_configs:
- api_url: https://api.telegram.org
bot_token: $BOT_TOKEN
chat_id: $CHAT_ID
send_resolved: true
- Prometheus configuration file:
global:
scrape_interval: 15s
evaluation_interval: 15s
alerting:
alertmanagers:
- static_configs:
- targets: ['[host-ip]:[port}']
rule_files:
- 'alert.yml'
scrape_configs:
- [various-configurations]
-
Logs: n/a
-
Notes: My logging stack is working well, but I would very much like to be able to target a particular topic in Telgram.
Hello, I agree that alertmanager need this feature.
There is no topic_id in telegram api. We have to add reply_to_message_id in GET request. When we reply to message "The topic "sometopic" was created" we actually send a message into this topic. I guess we should begin with:
DisableNotifications bool `yaml:"disable_notifications,omitempty" json:"disable_notifications,omitempty"`
ParseMode string `yaml:"parse_mode,omitempty" json:"parse_mode,omitempty"`
ReplyToMessageID int64 `yaml:"reply_to_message_id,omitempty" json:"reply_to_message_id,omitempty"`
}
https://github.com/efajunk/alertmanager/compare/main...efajunk-patch-1
Field is called message_thread_id
https://core.telegram.org/bots/api#sendmessage
#3332
Recommendation to implement message_thread_id and update <telegram_config> to include:
# ID of the message thread (topic) of the forum; for groups (optional)
[ message_thread_id [<int>](https://prometheus.io/docs/alerting/latest/configuration/#int) ]
There are two open PRs for this https://github.com/prometheus/alertmanager/pull/3560 and https://github.com/prometheus/alertmanager/pull/3638.
@grobinson-grafana We've had a few different PRs around this, and its very important to support this functionality. Right now we're in a world where everything is routed to the telegram equivalent of a #general chat on Slack with no ability to change the routing to avoid going to the whole organization.
I think https://github.com/prometheus/alertmanager/issues/3672 is ready to go to alleviate this issue.
I'm working with @th0th on #3638. Please follow that PR for updates.
Hi! 👋 #3638 has been merged! You can close the issue 🙂