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

Telegram API size limitation 4096? #65

Closed
darkfessing opened this issue Nov 28, 2023 · 3 comments
Closed

Telegram API size limitation 4096? #65

darkfessing opened this issue Nov 28, 2023 · 3 comments

Comments

@darkfessing
Copy link

Hey there! We try to use telepush for alertmanager notifications from our clusters. But we encounter situation, when not all notifications are delivered. After some investigations:

ts=XXXXXXXXXXXXX caller=dispatch.go:352 level=error component=dispatcher msg="Notify for alerts failed" num_alerts=21 err="telepush/webhook[0]: notify retry canceled due to unrecoverable error after 1 attempts: unexpected status code 400: https://telepush.dev/api/inlets/alertmanager/XXXXXX: message too long (max is 4096 characters)"

Some software deployed with Helm have multiply labels, and it`s easy-to-go to step over this limit. How this issue can be sold? Maybe force Telepush to short notifications size for Telegram eats it?

@muety
Copy link
Owner

muety commented Nov 28, 2023

This is a limitation by Telegram's API itself see here, so not much we can do against that. We could technically implement some piece of logic that split a message into multiple chunks, but I'd rather refrain from implementing that, tbh.

@muety muety closed this as completed Nov 28, 2023
@darkfessing
Copy link
Author

darkfessing commented Dec 7, 2023

Okay, but just in case: https://prometheus.io/docs/alerting/latest/configuration/#telegram_config

When using official docs, it's not pretty enough. But it works, message has been delivered. It's just became:
"level=warn integration=telegram msg="Truncated message"
...but most part of it is delivered (with "..." in the end).

When using telepush, we receive error, and message not delivered.

I've tried to overcame this with custom template, but it won't help:

  templates:
    limit_message_length.tmpl: |-
      {{- if gt (len .CommonAnnotations.message) 4000 }}
      {{ $shortMessage := slice .CommonAnnotations.message 0 4000 }}
      {{ $shortMessage }}
      ...
      {{- else }}
      {{ .CommonAnnotations.message }}
      {{- end }}

@muety
Copy link
Owner

muety commented Dec 8, 2023

This is the piece of code in alertmanager responsible for truncating the messages. We could implement the same in Wakapi. I'll create a new issue for this.

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

2 participants