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

Slack Integration: Should be able to mention a user or user group in an alert #19271

Closed
prateekm21 opened this issue Jun 10, 2020 · 36 comments
Closed

Comments

@prateekm21
Copy link

prateekm21 commented Jun 10, 2020

Summary

In slack alerts we should be able to set a user or user group mention

Motivation

There can be a slack user-group with on-call people. When critical alerts hits the channel we want to mention on call user group or any user

Additional Context

I have looked around and not able to find a way to add slack user mention in a notification so creating this issue

┆Issue is synchronized with this Jira Improvement by Unito

@Finkes
Copy link

Finkes commented Jul 9, 2020

this is would be very helpful for us as well.

@saifelse
Copy link
Contributor

A few workarounds that I've used with success:

  1. If you're using PagerDuty, the PagerDuty integration serves this purpose well.
  2. Alerts get directed to a specific channel, and via internal company process, ask that on-calls turn on Slack notifications for that channel on all messages.
  3. Run your own webhook server that is hit via the webhook integration, which gives the full capabilities of the Slack API.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2021

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Accepted, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@dandunckelman
Copy link

This still would be nice to have

@dean-ab
Copy link

dean-ab commented Feb 1, 2021

More than just mentions, would be very useful if we could add @channel mentions depends on the severity of the captured error.

@belm0
Copy link

belm0 commented Feb 26, 2021

It should just allow a custom message (which can include mentions), like other integrations do (e.g. Grafana's Slack integration for alerting).

@cheesepaulo
Copy link

cheesepaulo commented Aug 25, 2021

It should just allow a custom message (which can include mentions), like other integrations do (e.g. Grafana's Slack integration for alerting).

For sure, a simple @Team-Example solve my problem.

@prateekm21
Copy link
Author

@chadwhitacre What we can do to get this prioritize. This is a super simple but powerful improvement !

@naomichi-y
Copy link

naomichi-y commented Nov 10, 2021

I believe Sentry recently added support for notification by error frequency.
This feature is great, but since you can't specify a Mention in the Slack channel, it may get buried in other alerts.
It would be useful to be able to specify @channel or @oncall.

@snirbenyosef
Copy link

This still would be nice to have

@chadwhitacre
Copy link
Member

Bump @getsentry/ecosystem. Not sure if this is (still?) on your radar.

@ricoleabricot
Copy link

I don't know if it can helps but I have found a quick solution for this one

I saw there that sentry is calling Slack with:

payload = {
    ...
    "link_names": 1,
    ...
}

➡️ Which means any message printed in the Slack channel will link handles (people and team).

A quick solution is to use the tag property of the Sentry alert to add the slack handle to mention, like:

event["tags"]["slack_handle"] = @slack_handle_to_ping

➡️ It means knowing in your codebase which people to mention (not using natively the app to do that)

🏗️ This is a workaround solution but at least it enables to tag someone in the meantime

@nielsvaneck
Copy link

A quick solution is to use the tag property of the Sentry alert to add the slack handle to mention, like:

event["tags"]["slack_handle"] = @slack_handle_to_ping

The one missing piece of this puzzle is that you have to add the slack_handle tag name (or whatever you like to call this tag) to the "show tags [....] in notifications" field of the actions performed by your Alert Rule.

@snirbenyosef
Copy link

snirbenyosef commented Jul 3, 2022

@ricoleabricot
i'm not sure how to use the link_names, I can just put the SLACK_ID ?

@ricoleabricot
Copy link

Hey @snirbenyosef, sorry for the late answer.

The link_names is setup in the code of the slack package, you don't have to deal with it, it's already applied and tells that you can ping people through a Sentry alert.

What you need to do is, as @nielsvaneck said above, create an Alert Rule, and set the slack_handle in the shown tags of your alerts.

Then, when creating your Sentry event in your codebase (or catching it to add data), simply add the tag to it like I proposed in my initial answer :)

@snirbenyosef
Copy link

Thank you @ricoleabricot .
i have added slack_handle to tags like that:
tags[:slack_handle] = A123456

and then in sentry alert I add:
and show tags: slack_handle

but its still not pinging when slack message are sent, its just shows the A12345

any ideas what I'm doing wrong?

@ricoleabricot
Copy link

Hey @snirbenyosef, you need to add a @ before the handle to tag on Slack 😅
So, maybe @A123456 ?

@snirbenyosef
Copy link

thanks for the quick answer.
@ricoleabricot A123456 need to be the SLACK_ID or the name of the user in slack?

@ricoleabricot
Copy link

On my side I use the name of the user, or the user group's one 😄

@snirbenyosef
Copy link

snirbenyosef commented Jul 28, 2022

@ricoleabricot thanks working!

@relm923
Copy link

relm923 commented Sep 8, 2022

I'm struggling to get user mentions to work as well. I have the slack_handle tag flowing through and appearing in the Slack alert. I've tried using @USER_ID and @USERNAME. Both appear in the Slack alert but not actually notify the user

Any ideas what might be going wrong?

@toantk238
Copy link

I also faced with this issue. It can't mention the user/team. Any idea ?
image

@relm923
Copy link

relm923 commented Sep 14, 2022

Looks like Slack changed how user mentions specifically need to be formatted. Using <@_SLACK_USER_ID_> appears to be the magic format now

@katiejenkinswebdev
Copy link

Updating this issue from the Sentry side to add further context - we seem to still have the inability to tag a user in our Alerts. I've tested all the formats mentioned in this Issue (TY everyone!) by adding the Slack User ID (Examples: U04G038UN6A) to the ID field in the Alert and still receive a Notification failed when I send a Test Notification. 🙏🏻
Screen Shot 2023-02-01 at 4 41 18 PM

@realkosty
Copy link
Contributor

realkosty commented Feb 2, 2023

This is basically a Slack bug/feature.
Mentions inside attachment text (using <@U...> syntax) are highlighted and hoverable (see screenshot) but nevertheless don't show up in "@Mentions & reactions" and don't trigger notification.

I opened a help request with Slack regarding this at https://sentry-demo.slack.com/help/requests/4625909
But I can see how this might be by design.

We should be able to detect <@U...> in the text on our side and add it to message body as a workaround. @brianthi @Dhrumil-Sentry OR, we could simply move the entire alert name into the Slack message body and then Sentry users would put <@U12345678> into alert name itself, removing the need for custom tag. (In the screenshot below I'm putting user ID mention in both "slackMention" tag AND alert name)

Screenshot 2023-02-01 at 5 20 30 PM

Screenshot 2023-02-01 at 6 14 10 PM

@Akshay090
Copy link

Thanks @realkosty the above mentioned approach works, I'm able to get notification with that,
for anyone who comes across this, use alert name like below format
for tagging user - 0 error events in 1 minute <@U042E9V5KAA>
and for tagging a user group - 0 error events in 1 minute <!subteam^S022E9R5KAA>

@xenditjoshjimenez
Copy link

hey @realkosty @brianthi @Dhrumil-Sentry was wondering if this suggestion #19271 (comment) can be implemented by sentry team? since right now it doesn't do any notifications to to the tagged users/group. it would be really helpful if we can get notified, so we can have the respective users take a look right away

@getsantry
Copy link
Contributor

getsantry bot commented Nov 20, 2023

Routing to @getsentry/product-owners-settings-integrations for triage ⏲️

@Dhrumil-Sentry
Copy link

@xenditjoshjimenez We're considering adding this to the integration but we don't have any concrete timelines yet.

How would you use this feature? If Sentry allowed you to specify users to be tagged in the alert, would you keep changing the alert rule since the person on-call might keep changing?

@xenditjoshjimenez
Copy link

@xenditjoshjimenez We're considering adding this to the integration but we don't have any concrete timelines yet.

How would you use this feature? If Sentry allowed you to specify users to be tagged in the alert, would you keep changing the alert rule since the person on-call might keep changing?

ah no, our use case is it'll be fixed to tag a slack user group who's responsible for handling or managing the service

@mei-li
Copy link

mei-li commented Jan 17, 2024

We would also benefit from this feature, to make sure tags are noticed by our rotating slack group of on call people

@Dhrumil-Sentry
Copy link

@mei-li We plan on building this soon. Please see our discussion for more details: #61601

We will update this issue once we know more

@realkosty
Copy link
Contributor

This is already available in product.
Please make sure to use <@user_Id> syntax.

copy-member-id

More info in the other thread: #61601 (comment)

@ceorourke
Copy link
Member

There is now a "notes" section available when creating an alert rule for Slack. You can read more about the updates we've added here.

@phyzical
Copy link

phyzical commented Apr 5, 2024

It looks like this might have been missed in the api? https://docs.sentry.io/api/alerts/create-an-issue-alert-rule-for-a-project/

or is this docs side only its missing?

this is now causing drift in our IAC, im just trying to narrow down if its an api issue or if there logic in the terraform provider that needs adjusting

@github-actions github-actions bot locked and limited conversation to collaborators Apr 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Archived in project
Development

No branches or pull requests