-
-
Notifications
You must be signed in to change notification settings - Fork 592
feat(alerting): Implement new Teams Workflow alert #847
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
Conversation
Signed-off-by: James Hillyard <[email protected]>
Signed-off-by: James Hillyard <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! The only real change I see here is renaming teamsworkflowtoteams-workflows`.
Not a super big deal, but looking at https://support.microsoft.com/en-us/office/creating-a-workflow-from-a-channel-in-teams-242eb8f2-f328-45be-b81f-9817b51a5f0e, it seems like their service is "Workflows", not "Workflow", and well, I'd rather avoid confusion.
In a later version of Gatus, I'll probably get rid of the current teams once they get rid of the O365 connectors and replace it for this implementation.
Signed-off-by: James Hillyard <[email protected]>
|
@TwiN Makes sense, I have renamed |
Signed-off-by: James Hillyard <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JamesHillyard Looks like some of your tests are failing
--- FAIL: TestAlertProvider_buildRequestBody (0.00s)
--- FAIL: TestAlertProvider_buildRequestBody/triggered (0.00s)
teamsworkflows_test.go:189: expected:
{"attachments":[{"content":{"type":"AdaptiveCard","version":"1.4","body":[{"type":"TextBlock","text":"\u0026#x1f6a8 Gatus","wrap":false,"size":"Medium","weight":"Bolder"},{"type":"TextBlock","text":"An alert for **endpoint-name** has been triggered due to having failed 3 time(s) in a row.","wrap":true},{"type":"FactSet","wrap":false,"facts":[{"title":"\u0026#x274C;","value":"[CONNECTED] == true"},{"title":"\u0026#x274C;","value":"[STATUS] == 200"}]}]},"contentType":"application/vnd.microsoft.card.adaptive"}],"type":"message"}
got:
{"attachments":[{"content":{"type":"AdaptiveCard","version":"1.4","body":[{"type":"TextBlock","text":"\u0026#x26D1; Gatus","wrap":false,"size":"Medium","weight":"Bolder"},{"type":"TextBlock","text":"An alert for **endpoint-name** has been triggered due to having failed 3 time(s) in a row.","wrap":true},{"type":"FactSet","wrap":false,"facts":[{"title":"\u0026#x274C;","value":"[CONNECTED] == true"},{"title":"\u0026#x274C;","value":"[STATUS] == 200"}]}]},"contentType":"application/vnd.microsoft.card.adaptive"}],"type":"message"}
--- FAIL: TestAlertProvider_buildRequestBody/resolved (0.00s)
teamsworkflows_test.go:189: expected:
{"attachments":[{"content":{"type":"AdaptiveCard","version":"1.4","body":[{"type":"TextBlock","text":"\u0026#x1f6a8 Gatus","wrap":false,"size":"Medium","weight":"Bolder"},{"type":"TextBlock","text":"An alert for **endpoint-name** has been resolved after passing successfully 5 time(s) in a row.","wrap":true},{"type":"FactSet","wrap":false,"facts":[{"title":"\u0026#x2705;","value":"[CONNECTED] == true"},{"title":"\u0026#x2705;","value":"[STATUS] == 200"}]}]},"contentType":"application/vnd.microsoft.card.adaptive"}],"type":"message"}
got:
{"attachments":[{"content":{"type":"AdaptiveCard","version":"1.4","body":[{"type":"TextBlock","text":"\u0026#x26D1; Gatus","wrap":false,"size":"Medium","weight":"Bolder"},{"type":"TextBlock","text":"An alert for **endpoint-name** has been resolved after passing successfully 5 time(s) in a row.","wrap":true},{"type":"FactSet","wrap":false,"facts":[{"title":"\u0026#x2705;","value":"[CONNECTED] == true"},{"title":"\u0026#x2705;","value":"[STATUS] == 200"}]}]},"contentType":"application/vnd.microsoft.card.adaptive"}],"type":"message"}
--- FAIL: TestAlertProvider_buildRequestBody/resolved-with-no-conditions (0.00s)
teamsworkflows_test.go:189: expected:
{"attachments":[{"content":{"type":"AdaptiveCard","version":"1.4","body":[{"type":"TextBlock","text":"\u0026#x1f6a8 Gatus","wrap":false,"size":"Medium","weight":"Bolder"},{"type":"TextBlock","text":"An alert for **endpoint-name** has been resolved after passing successfully 5 time(s) in a row.","wrap":true},{"type":"FactSet","wrap":false}]},"contentType":"application/vnd.microsoft.card.adaptive"}],"type":"message"}
got:
{"attachments":[{"content":{"type":"AdaptiveCard","version":"1.4","body":[{"type":"TextBlock","text":"\u0026#x26D1; Gatus","wrap":false,"size":"Medium","weight":"Bolder"},{"type":"TextBlock","text":"An alert for **endpoint-name** has been resolved after passing successfully 5 time(s) in a row.","wrap":true},{"type":"FactSet","wrap":false}]},"contentType":"application/vnd.microsoft.card.adaptive"}],"type":"message"}
FAIL
coverage: 93.5% of statements
FAIL github.com/TwiN/gatus/v5/alerting/provider/teamsworkflows 0.026s
Signed-off-by: James Hillyard <[email protected]>
|
@TwiN Looks like the text was expecting a broken teams emoji.. I must have changed it last minute and not updated the test. I've now fixed it and running |
|
When can I use the new teams-workflows? |
|
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #847 +/- ##
==========================================
+ Coverage 79.15% 79.35% +0.19%
==========================================
Files 71 72 +1
Lines 4778 4853 +75
==========================================
+ Hits 3782 3851 +69
- Misses 783 786 +3
- Partials 213 216 +3 ☔ View full report in Codecov by Sentry. |
|
@JamesHillyard Great work & thank you for the contribution! |
|
@TwiN not pushing you, but any idea when you'll create a new release including this code? |
|
@liamjones-pw I usually let new features soak in latest for some time to give people time to report issues. If people are already using the feature and haven't reported any issues, I can create a release for it this weekend 👀 |
|
@liamjones-pw I just released v5.13.0 |
Summary
Fixes #820 by introducing a new
teams-workflowsalert compatible with Teams Workflows. Microsoft is deprecating the O365 webhook connector for Teams Workflows with MS Power Automate (Source: Microsoft DevBlog).The new Workflows require Microsoft Adaptive Cards and have a proprietary JSON format that means the old
teamsconnector using a new Workflow URL will fail with this error:Breaking Changes
There are no breaking changes. The old
teamsalert still exists and will work with legacy O365 Webhook URLs.There are no breaking changes in configuring the
teamsandteamswebhookalerts, meaning migration is simple.Migrating to new Teams Webhooks
End-users will need to make the following changes to migrate from the legacy
teamsalerts toteamswebhookalerts:teams(Inalertingandendpoints[].alerts) withteams-workflowsalerting.teams.webhook-url(Nowalerting.teams-workflows.webhook-url) with the new URL generated in the Teams WorkflowConfiguring the
teams-workflowsAlertMS Teams Configuration
Gatus Configuration
Remaining Issues
There are a few remaining issues, none are blockers to using this feature, but likely should be addressed in the future with further investigation.
Adaptive Card Version >1.5
Using an Adaptive Card higher than 1.4 (1.6 is latest) results in the message showing
This has been reported to AdaptiveCards (Report), but discussion around this issue seems very low.
Card Width
The cards do not show on teams as full-width. A StackOverflow post would suggest the width can be changed, but I wasn't able to get this to work.
Card Colour Strip
The red and green colour strip on the old teams cards at the top for triggered/resolved is not supported in Adaptive Cards. There are workaround options as identified in this Stack Overflow post but it doesn't look great.
Checklist
README.md, if applicable.