Skip to content
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

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

Open
instantdreams opened this issue Jan 16, 2024 · 8 comments
Open

Comments

@instantdreams
Copy link

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: d7b4f0c)
    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.

@Scealang
Copy link

Scealang commented Feb 5, 2024

Hello, I agree that alertmanager need this feature.

@efajunk
Copy link

efajunk commented Feb 6, 2024

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"`
}

efajunk/alertmanager@main...efajunk-patch-1

@we1rdw4y
Copy link

we1rdw4y commented Feb 11, 2024

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

#3332

@instantdreams
Copy link
Author

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) ]

@grobinson-grafana
Copy link
Contributor

There are two open PRs for this #3560 and #3638.

@Ryan-DL
Copy link

Ryan-DL commented Apr 23, 2024

@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 #3672 is ready to go to alleviate this issue.

@grobinson-grafana
Copy link
Contributor

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

@grobinson-grafana
Copy link
Contributor

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

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

No branches or pull requests

6 participants