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

Truncate messages to fit maximum length limitation #66

Closed
muety opened this issue Dec 8, 2023 · 6 comments
Closed

Truncate messages to fit maximum length limitation #66

muety opened this issue Dec 8, 2023 · 6 comments

Comments

@muety
Copy link
Owner

muety commented Dec 8, 2023

Discussed in #65. Roughly copy alertmanager's implementation. Also, add a config option so that a server admin can choose whether to reject too long messages (as it's currently the case) or truncate them.

@darkfessing
Copy link

darkfessing commented Dec 28, 2023

Looks like nothing changed? Or just telepush.dev was not updated? Tested today:

ts=2023-12-28T18:11:28.857Z caller=dispatch.go:352 level=error component=dispatcher msg="Notify for alerts failed" num_alerts=4 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)"

@muety
Copy link
Owner Author

muety commented Dec 28, 2023

Telepush.dev has the truncation feature disabled, it will continue rejecting too long messages.

@darkfessing
Copy link

darkfessing commented Dec 28, 2023

Ohh i get it. Able to use it by building my own telepush docker image (current release don`t include new -truncateMsgs option). And launch it in local network (in pool mode). Some alerts are OK.

But I got some new errors. Looks like it is related to new -truncateMsgs feature.. or something else?

alertmanager error:
ts=2023-12-28T19:29:28.997Z caller=dispatch.go:352 level=error component=dispatcher msg="Notify for alerts failed" num_alerts=3 err="telepush/webhook[0]: notify retry canceled due to unrecoverable error after 1 attempts: unexpected status code 400: http://1.1.X.XXX:8080/api/inlets/alertmanager/XXXXX: telegram api returned status 400: 'Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 3781'\n"

telepush error:
2023/12/28 19:29:28 error: telegram api returned status 400: 'Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 3781'

Thx for advance!

@muety
Copy link
Owner Author

muety commented Dec 28, 2023

This error usually occurs when the text you're sending contains reserved Markdown characters without actually being Markdown, e.g. when there is an underscore (_) (standing for italic text in Markdown) without a second, "closing" underscore. Normally, these characters should get escaped, but not sure, if they're actually all being covered. Can you check if your text contains anything unusual? Perhaps even post it here, if not containing any sensitive data?

@darkfessing
Copy link

darkfessing commented Dec 28, 2023

Looks like I need to capture alertmanager notifications some way. Not really sure how to do that.

This is notification captured by telegram:

telegram_configs:
          parse_mode: ''

From alertmanager logs:
ts=2023-12-28T20:23:28.805Z caller=telegram.go:85 level=warn integration=telegram msg="Truncated message" alert="{}:{alertname=\"HostCpuIsUnderutilized\", instance=\"172.16.1.177:9100\", namespace=\"prometheus-stack\", severity=\"info\"}" max_runes=4096

Notification text:
error.txt

@muety
Copy link
Owner Author

muety commented Dec 28, 2023

I created #67, which will solve your problem. Will hopefully get to implementing this very soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants