prometheus / alertmanager

Prometheus Alertmanager
https://prometheus.io
Apache License 2.0
6.7k stars 2.17k forks source link

Request: Add topic_id as an optional parameter to telegram_config #3672

Open instantdreams opened 10 months ago

instantdreams commented 10 months ago

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

route: group_by: ['alertname'] group_wait: 30s group_interval: 30s repeat_interval: 5m receiver: 'id-telegram'

receivers:

alerting: alertmanagers:

rule_files:

scrape_configs:

Scealang commented 10 months ago

Hello, I agree that alertmanager need this feature.

efajunk commented 10 months ago

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

we1rdw4y commented 9 months ago

Field is called message_thread_id https://core.telegram.org/bots/api#sendmessage

3332

instantdreams commented 9 months ago

Recommendation to implement message_thread_id and update 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) ]
grobinson-grafana commented 7 months ago

There are two open PRs for this https://github.com/prometheus/alertmanager/pull/3560 and https://github.com/prometheus/alertmanager/pull/3638.

Ryan-DL commented 7 months ago

@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.

grobinson-grafana commented 7 months ago

I'm working with @th0th on #3638. Please follow that PR for updates.

grobinson-grafana commented 7 months ago

Hi! 👋 #3638 has been merged! You can close the issue 🙂