Skip to content

Telegram sink sends small TableBlocks as sendDocument .txt attachments #2167

Description

@RaviTharuma

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:

  1. Never sendDocument for text under 1KB. Small tables (Alert labels, etc.) belong in the finding message.
  2. sendMessage with parse_mode=HTML (not MarkdownV2). Escape &, <, > in user/table text.
  3. Put labels/tables in <blockquote expandable>…</blockquote> so they collapse on mobile.
  4. Use link_preview_options: { is_disabled: true } unless the attachment is a graph/image.
  5. If the HTML text is over 4096 characters, split into sequential sendMessage calls. Do not fall back to a .txt document for overflow.
  6. Keep send_files for real FileBlock images/graphs (sendPhoto / actual files), not for table text.

How to reproduce

  1. Configure telegram_sink with default send_files: true.
  2. Fire a Prometheus/Alertmanager finding whose enrichments include a small TableBlock (Alert labels).
  3. 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)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions