find Author from slack

main
Bel LaPointe 2024-04-16 07:35:58 -06:00
parent 5fa21d0cd9
commit 5bc068451f
2 changed files with 8 additions and 0 deletions

View File

@ -98,6 +98,7 @@ type (
Asset string
Resolved bool
Datacenter string
Author string
}
slackMessage struct {
@ -118,6 +119,7 @@ type (
ParentID string `json:"thread_ts"`
Text string
Blocks []slackBlock
User string
// bot
Bot slackBot `json:"bot_profile"`
Attachments []slackAttachment
@ -188,6 +190,7 @@ func parseSlack(b []byte) (parsedSlackMessage, error) {
Asset: s.Event.Attachments[0].Text,
Resolved: !strings.HasPrefix(s.Event.Attachments[0].Color, "F"),
Datacenter: tagsField,
Author: s.Event.Bot.Name,
}, nil
}
@ -205,6 +208,7 @@ func parseSlack(b []byte) (parsedSlackMessage, error) {
Plaintext: s.Event.Text,
Asset: "",
Datacenter: "",
Author: s.Event.User,
}, nil
}

View File

@ -129,6 +129,7 @@ func TestParseSlackTestdata(t *testing.T) {
Event: "",
Plaintext: "I gotta do this",
Asset: "",
Author: "U06868T6ADV",
},
},
"opsgenie_alert.json": {
@ -164,6 +165,7 @@ func TestParseSlackTestdata(t *testing.T) {
Plaintext: "At least one alertconfig run has failed unexpectedly.\nDashboard: <https://grafana.render.com/d/VLZU83YVk?orgId=1>\nPanel: <https://grafana.render.com/d/VLZU83YVk?orgId=1&amp;viewPanel=17>\nSource: <https://grafana.render.com/alerting/grafana/fa7b06b8-b4d8-4979-bce7-5e1c432edd81/view?orgId=1>",
Asset: "At least one alertconfig run has failed unexpectedly.\nDashboard: <https://grafana.render.com/d/VLZU83YVk?orgId=1>\nPanel: <https://grafana.render.com/d/VLZU83YVk?orgId=1&amp;viewPanel=17>\nSource: <https://grafana.render.com/alerting/grafana/fa7b06b8-b4d8-4979-bce7-5e1c432edd81/view?orgId=1>",
Datacenter: "alertname:Alertconfig Workflow Failed, grafana_folder:Datastores, rule_uid:a7639f7e-6950-41be-850a-b22119f74cbb",
Author: "Opsgenie for Alert Management",
},
},
"opsgenie_alert_resolved.json": {
@ -200,6 +202,7 @@ func TestParseSlackTestdata(t *testing.T) {
Asset: "At least one alertconfig run has failed unexpectedly.\nDashboard: <https://grafana.render.com/d/VLZU83YVk?orgId=1>\nPanel: <https://grafana.render.com/d/VLZU83YVk?orgId=1&amp;viewPanel=17>\nSource: <https://grafana.render.com/alerting/grafana/fa7b06b8-b4d8-4979-bce7-5e1c432edd81/view?orgId=1>",
Resolved: true,
Datacenter: "alertname:Alertconfig Workflow Failed, grafana_folder:Datastores, rule_uid:a7639f7e-6950-41be-850a-b22119f74cbb",
Author: "Opsgenie for Alert Management",
},
},
"reingested_alert.json": {
@ -215,6 +218,7 @@ func TestParseSlackTestdata(t *testing.T) {
Asset: "At least one alertconfig run has failed unexpectedly.\nDashboard: <https://grafana.render.com/d/VLZU83YVk?orgId=1>\nPanel: <https://grafana.render.com/d/VLZU83YVk?orgId=1&amp;viewPanel=17>\nSource: <https://grafana.render.com/alerting/grafana/fa7b06b8-b4d8-4979-bce7-5e1c432edd81/view?orgId=1>",
Resolved: true,
Datacenter: "alertname:Alertconfig Workflow Failed, grafana_folder:Datastores, rule_uid:a7639f7e-6950-41be-850a-b22119f74cbb",
Author: "Opsgenie for Alert Management",
},
},
}