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

[AppMentionEvent] can not get grafana alerts text #1151

Open
sven0219 opened this issue Dec 22, 2022 · 3 comments
Open

[AppMentionEvent] can not get grafana alerts text #1151

sven0219 opened this issue Dec 22, 2022 · 3 comments

Comments

@sven0219
Copy link

sven0219 commented Dec 22, 2022

What happened

image
As shown in the screenshot, I use grafana to send a test alerts, but the text of the alerts cannot be obtained in slackbot. The following is my code

func middlewareAppMentionEvent(evt *socketmode.Event, client *socketmode.Client) {
	eventsAPIEvent, ok := evt.Data.(slackevents.EventsAPIEvent)
	if !ok {
		logger.Info("Ignored %+v\n", evt)
		return
	}
	client.Ack(*evt.Request)
	ev, ok := eventsAPIEvent.InnerEvent.Data.(*slackevents.AppMentionEvent)
	logger.Info("evText----------->", ev.Text)
	logger.Info("evType----------->", ev.Type)
	if !ok {
		logger.Info("Ignored %+v\n", ev)
		return
	}
...
...

The log is as follows

...
{"level":"info","ts":"2022-12-22T09:44:42+08:00","msg":"evText-----------> "}
{"level":"info","ts":"2022-12-22T09:44:42+08:00","msg":"evType----------->app_mention"}
...

Expected behavior

When I ping the robot like this
image
the logs like this:

...
{"level":"info","ts":"2022-12-22T10:00:57+08:00","msg":"evText-----------><@U03***LRF>  Hello world"}
{"level":"info","ts":"2022-12-22T10:00:57+08:00","msg":"evType----------->app_mention"}
...

I'm not sure why I can't get the grafana alerts text

Versions

  • Go: 1.19.3
  • slack-go/slack: v0.11.3
@kanata2
Copy link
Member

kanata2 commented Dec 24, 2022

Could you try to log evt.Data?

@kanata2 kanata2 added needs review feedback given When a review has been conducted and awaiting the response from the comitter(s) labels Dec 24, 2022
@sven0219
Copy link
Author

Sorry for reply so late.
Code for log evt.Data

func middlewareAppMentionEvent(evt *socketmode.Event, client *socketmode.Client) {
	eventsAPIEvent, ok := evt.Data.(slackevents.EventsAPIEvent)
	logger.Info("evt.Data---->", evt.Data)
	if !ok {
		logger.Info("Ignored %+v\n", evt)
		return
	}
...

log

{"level":"info","ts":"2023-01-11T18:07:09+08:00","msg":"evt.Data---->{AwKZMkAdB1AbFuoc6sn1j9fA T024GQDB5 event_callback A03GSSXUTNY  0xc0000ca460 {app_mention 0xc0000ca500}}"}

slack msg
image

@github-actions
Copy link

github-actions bot commented Apr 5, 2023

This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the stale label Apr 5, 2023
@kanata2 kanata2 removed the stale label Apr 5, 2023
@kanata2 kanata2 removed the feedback given When a review has been conducted and awaiting the response from the comitter(s) label Apr 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants