Skip to main content

Multi-column status report

Present a compact service report using native table cells. The code and preview use the same selected-language output.

Output

Local preview of the selected language’s tested example. Slack client appearance may differ; controls here do not send requests.

Servicep99 (ms)Errors
api1423
worker890
billing31012
Serialized output
{
"channel": "#ops",
"mrkdwn": true,
"blocks": [
{
"type": "table",
"block_id": "<generated-block-id>",
"rows": [
[
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "Service",
"style": {
"bold": true
}
}
]
}
]
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "p99 (ms)",
"style": {
"bold": true
}
}
]
}
]
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "Errors",
"style": {
"bold": true
}
}
]
}
]
}
],
[
{
"type": "raw_text",
"text": "api"
},
{
"type": "raw_text",
"text": "142"
},
{
"type": "raw_text",
"text": "3"
}
],
[
{
"type": "raw_text",
"text": "worker"
},
{
"type": "raw_text",
"text": "89"
},
{
"type": "raw_text",
"text": "0"
}
],
[
{
"type": "raw_text",
"text": "billing"
},
{
"type": "raw_text",
"text": "310"
},
{
"type": "raw_text",
"text": "12"
}
]
],
"column_settings": [
{
"align": "left"
},
{
"align": "right"
},
{
"align": "right"
}
]
}
],
"text": "Daily service report"
}

Code​

TableBlock is useful for compact tabular output.

from slackblocks import (
ColumnSettings,
Message,
RawText,
RichText,
RichTextSection,
TableBlock,
)


def header_cell(text: str) -> RichTextSection:
return RichTextSection(elements=[RichText(text=text, bold=True)])


report = Message(
channel="#ops",
text="Daily service report",
blocks=[
TableBlock(
column_settings=[
ColumnSettings(align="left"),
ColumnSettings(align="right"),
ColumnSettings(align="right"),
],
rows=[
[header_cell("Service"), header_cell("p99 (ms)"), header_cell("Errors")],
[RawText("api"), RawText("142"), RawText("3")],
[RawText("worker"), RawText("89"), RawText("0")],
[RawText("billing"), RawText("310"), RawText("12")],
],
),
],
)
print(report.json())