Description
telegram_sink always ships every TableBlock as a Telegram document (sendDocument / sendFile) named {table_name}.txt, including tables that are only a few hundred bytes (typical Alertmanager label tables).
The sink also excludes TableBlock from the main message text:
# telegram_sink.py __is_telegram_text_block
# enrichments text tables are too big for mobile device
return not (isinstance(block, FileBlock) or isinstance(block, TableBlock))
and, when send_files is true (the default), uploads the table as a file:
table_text = tabulate(block.render_rows(), headers=block.headers, tablefmt="presto")
table_name = block.table_name if block.table_name else "table"
self.client.send_file(file_name=f"{table_name}.txt", contents=table_text.encode("utf-8"))
Docs currently say tables are sent as file attachments because they are too big for Telegram clients. That is not true for small tables (Alert labels are typically well under 1KB).
Related but not a duplicate: #2137 (Telegram interactivity / titles). Official sink docs: https://docs.robusta.dev/master/configuration/sinks/telegram.html
Expected behavior
Per Telegram Bot API / HTML style:
- Never
sendDocument for text under 1KB. Small tables (Alert labels, etc.) belong in the finding message.
sendMessage with parse_mode=HTML (not MarkdownV2). Escape &, <, > in user/table text.
- Put labels/tables in
<blockquote expandable>…</blockquote> so they collapse on mobile.
- Use
link_preview_options: { is_disabled: true } unless the attachment is a graph/image.
- If the HTML text is over 4096 characters, split into sequential
sendMessage calls. Do not fall back to a .txt document for overflow.
- Keep
send_files for real FileBlock images/graphs (sendPhoto / actual files), not for table text.
How to reproduce
- Configure
telegram_sink with default send_files: true.
- Fire a Prometheus/Alertmanager finding whose enrichments include a small
TableBlock (Alert labels).
- Telegram receives a
{table_name}.txt document instead of inline text.
Environment
- Component:
src/robusta/core/sinks/telegram/telegram_sink.py, telegram_client.py
send_files default: True (telegram_sink_params.py)
Description
telegram_sinkalways ships everyTableBlockas a Telegram document (sendDocument/sendFile) named{table_name}.txt, including tables that are only a few hundred bytes (typical Alertmanager label tables).The sink also excludes
TableBlockfrom the main message text:and, when
send_filesis true (the default), uploads the table as a file:Docs currently say tables are sent as file attachments because they are too big for Telegram clients. That is not true for small tables (Alert labels are typically well under 1KB).
Related but not a duplicate: #2137 (Telegram interactivity / titles). Official sink docs: https://docs.robusta.dev/master/configuration/sinks/telegram.html
Expected behavior
Per Telegram Bot API / HTML style:
sendDocumentfor text under 1KB. Small tables (Alert labels, etc.) belong in the finding message.sendMessagewithparse_mode=HTML(not MarkdownV2). Escape&,<,>in user/table text.<blockquote expandable>…</blockquote>so they collapse on mobile.link_preview_options: { is_disabled: true }unless the attachment is a graph/image.sendMessagecalls. Do not fall back to a.txtdocument for overflow.send_filesfor realFileBlockimages/graphs (sendPhoto/ actual files), not for table text.How to reproduce
telegram_sinkwith defaultsend_files: true.TableBlock(Alert labels).{table_name}.txtdocument instead of inline text.Environment
src/robusta/core/sinks/telegram/telegram_sink.py,telegram_client.pysend_filesdefault:True(telegram_sink_params.py)