Skip to content

Alerting: Migrate Slack to use Block Kit#427

Draft
TimShilov wants to merge 4 commits intografana:mainfrom
TimShilov:feature/slack-block-kit
Draft

Alerting: Migrate Slack to use Block Kit#427
TimShilov wants to merge 4 commits intografana:mainfrom
TimShilov:feature/slack-block-kit

Conversation

@TimShilov
Copy link

Note

This is a rough draft, just to start the conversation and get some guidance. It's not polished and not well tested yet.
I'd like to know first, is it something worth finalizing and would maintainers consider merging it if I'll do so?

In this PR I attempted to migrate existing Slack receiver to use Block Kit instead of the legacy attachments (which are discouraged from using by the Slack documentation).
I have migrated it according to the official migration guide.

In this initial migration PR I've tried not to change the way notifications actually look at the moment.

Here's the example of how test alert looked like BEFORE and AFTER the change:

BEFORE:

Before

AFTER:

After

The only visual differences between BEFORE and AFTER are:

  • Spacing between title and message is a bit different (arguably, it is better than before)
  • The icon in the footer looks a bit bigger and is better aligned
  • The timestamp that said "Today at 16:31" is missing in the footer. It is possible to replicate using date formatting, though I couldn't find the exact format AND I really don't see the point in having this timestamp to begin with given that the message itself has the timestamp already. 🤷‍♂️

Hopefully, if this will be merged, then it will be possible to actually improve the layout of the Slack notifications to make them look better, and maybe even try to address grafana/grafana#82843 and grafana/grafana#80374 somehow.

Questions/problems to address:

  1. There's one problem I haven't found the solution to - the fallback field. The documentation suggests to use top-level text instead and it works just fine but ONLY if there's anything in top-level blocks as well. I've put mentions in that, but if Contact Point isn't configured to mention anyone - then the blocks is empty and text is actually displayed. So the only way to workaround this is to always have something inside top-level blocks. It might be a good idea to put the title outside of attachments but that will look very different from the current notifications.
Here's what that could look like

Using markdown

Screenshot 2025-11-28 at 17 04 23

Using header

Screenshot 2025-11-28 at 17 06 44
  1. Apparently, Slack doesn't recommend using attachments field at all, but it seems to be the only way to create the colored border. I wonder if we should consider getting rid of the colored border? That not only would allow us to stop using deprecated field, but also would solve the above-mentioned issue with fallback... but the color looks nice. 😬

@CLAassistant
Copy link

CLAassistant commented Nov 28, 2025

CLA assistant check
All committers have signed the CLA.

@YashIngole
Copy link

Any update on this PR?

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

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants