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

feat(3920): add msteamsv2 receiver #4024

Merged
merged 7 commits into from
Oct 23, 2024
Merged

feat(3920): add msteamsv2 receiver #4024

merged 7 commits into from
Oct 23, 2024

Conversation

sschne
Copy link
Contributor

@sschne sschne commented Sep 6, 2024

fixes #3920

This is based on the work done in #3921 from @zhan9san. It creates a new receiver as requested in the Review.

If you can come up with a better name than msteamsv2, please let me know :)

Signed-off-by: Simon Schneider <[email protected]>
@praveenjindal62
Copy link

@simonpasquier @w0rm @gotjosh could you please help here ? msteams webhook deprecation date is near and we need some working solution with msteams workflows to migrate our workloads to.

@trenslow
Copy link

Thanks so much for the implementation @sschne. I just have one comment. I don't fully understand the code as I'm not a Go dev, but I was just wondering if you considered the following point. Does it really make sense to create a v2 receiver to be used by Alertmanager consumers?

As I understand, the receiver can be migrated in place to the new AdaptiveCard format, as the old Teams webhook accepts this input. This would also give Altermanager some time to iron out any issues in the payload sent to Teams. Then, as people get time to switch to PowerAutomate, they just need to change the URL and it should work out of the box.

This approach was taken by the Flux Notification Controller team in fluxcd/notification-controller#920 and for me the migration went smoothly. I updated to the latest Notification Controller and confirmed the AdaptiveCard was working in the webhook. Then I created the PowerAutomate workflow and simply switched the URL from the old webhook connector to the new workflow and the migration went through without any downtime.

The guys who worked on the Notification Controller added logic that would send a certain payload based on the webhook URL, just like what was proposed in #3921, which may add an extra layer of safety if users have highly customized their Teams payloads on the Alertmanager config side.

I guess internally, it makes sense to create a concept of an msteams v2 receiver, but from the consumer perspective, it might slow down adoption and increase time of maintenance.

@gotjosh gotjosh mentioned this pull request Oct 22, 2024
@grobinson-grafana
Copy link
Contributor

As I understand, the receiver can be migrated in place to the new AdaptiveCard format, as the old Teams webhook accepts this input.

The main issue we have in Alertmanager is the Summary field. It no longer seems to work with Adaptive Cards or Automate Workflows. Adding a v2 receiver will allow it be to be removed without causing breaking changes for existing users (need to consider that other software like Cortex and Mimir is built on top of Alertmanager too).

config/config.go Outdated Show resolved Hide resolved
config/notifiers.go Outdated Show resolved Hide resolved
config/notifiers.go Outdated Show resolved Hide resolved
docs/configuration.md Outdated Show resolved Hide resolved
docs/configuration.md Outdated Show resolved Hide resolved
notify/msteamsv2/msteamsv2.go Show resolved Hide resolved
return false, err
}

level.Debug(n.logger).Log("incident", key)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is incident referring to? Is this left over from testing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is not great - but it's common in other receivers: https://github.com/search?q=repo%3Aprometheus%2Falertmanager%20%22incident%22&type=code

I left it as is because at least it aligns with others.

@gotjosh gotjosh merged commit d4009f5 into prometheus:main Oct 23, 2024
11 checks passed
@gotjosh
Copy link
Member

gotjosh commented Oct 23, 2024

Thank you very much all of you for your contributions!

mogoll92 pushed a commit to staketown/alertmanager that referenced this pull request Oct 23, 2024
* feat(3920): add msteamsv2 receiver

Signed-off-by: Simon Schneider <[email protected]>

* Don't use `fmt.Errorf` when there's no formatting required on `config/config.go`

Signed-off-by: gotjosh <[email protected]>

* Don't use `fmt.Errorf` when there's no formatting required on `config/notifiers.go`

Signed-off-by: gotjosh <[email protected]>

* Remove additional documentation steps

Signed-off-by: gotjosh <[email protected]>

* add more info to the documentation

Signed-off-by: gotjosh <[email protected]>

* Change documentation links to convey the message better

Signed-off-by: gotjosh <[email protected]>

---------

Signed-off-by: Simon Schneider <[email protected]>
Signed-off-by: gotjosh <[email protected]>
Co-authored-by: gotjosh <[email protected]>
mogoll92 added a commit to staketown/alertmanager that referenced this pull request Oct 23, 2024
@sschne sschne deleted the f/3920 branch October 24, 2024 13:16
gotjosh added a commit that referenced this pull request Oct 24, 2024
* Release v0.28.0-rc.0

* [CHANGE] Templating errors in the SNS integration now return an error. #3531 #3879
* [FEATURE] Add a new Microsoft Teams integration based on Flows #4024
* [FEATURE] Add a new Rocket.Chat integration #3600
* [FEATURE] Add a new Jira integration #3590 #3931
* [FEATURE] Add support for `GOMEMLIMIT`, enable it via the feature flag `--enable-feature=auto-gomemlimit`. #3895
* [FEATURE] Add support for `GOMAXPROCS`, enable it via the feature flag `--enable-feature=auto-gomaxprocs`. #3837
* [FEATURE] Add support for limits of silences including the maximum number of active and pending silences, and the maximum size per silence (in bytes). You can use the flags `--silences.max-silences` and `--silences.max-silence-size-bytes` to set them accordingly #3852 #3862 #3866 #3885 #3886 #3877
* [FEATURE] Muted alerts now show whether they are suppressed or not in both the `/api/v2/alerts` endpoint and the Alertmanager UI. #3793 #3797 #3792
* [ENHANCEMENT] Add support for `content`, `username` and `avatar_url` in the Discord integration. `content` and `username` also support templating. #4007
* [ENHANCEMENT] Only invalidate the silences cache if a new silence is created or an existing silence replaced - should improve latency on both `GET api/v2/alerts` and `POST api/v2/alerts` API endpoint. #3961
* [ENHANCEMENT] Add image source label to Dockerfile. To get changelogs shown when using Renovate #4062
* [ENHANCEMENT] Build using go 1.23 #4071
* [ENHANCEMENT] Support setting a global SMTP TLS configuration. #3732
* [ENHANCEMENT] The setting `room_id` in the WebEx integration can now be templated to allow for dynamic room IDs. #3801
* [ENHANCEMENT] Enable setting `message_thread_id` for the Telegram integration. #3638
* [ENHANCEMENT] Support the `since` and `humanizeDuration` functions to templates. This means users can now format time to more human-readable text. #3863
* [ENHANCEMENT] Support the `date` and `tz` functions to templates. This means users can now format time in a specified format and also change the timezone to their specific locale. #3812
* [ENHANCEMENT] Latency metrics now support native histograms. #3737
* [BUGFIX] Fix the SMTP integration not correctly closing an SMTP submission, which may lead to unsuccessful dispatches being marked as successful. #4006
* [BUGFIX]  The `ParseMode` option is now set explicitly in the Telegram integration. If we don't HTML tags had not been parsed by default. #4027
* [BUGFIX] Fix a memory leak that was caused by updates silences continuously. #3930
* [BUGFIX] Fix hiding secret URLs when the URL is incorrect. #3887
* [BUGFIX] Fix a race condition in the alerts - it was more of a hypothetical race condition that could have occurred in the alert reception pipeline. #3648
* [BUGFIX] Fix a race condition in the alert delivery pipeline that would cause a firing alert that was delivered earlier to be deleted from the aggregation group when instead it should have been delivered again. #3826
* [BUGFIX] Fix version in APIv1 deprecation notice. #3815
* [BUGFIX] Fix crash errors when using `url_file` in the Webhook integration. #3800
* [BUGFIX] fix `Route.ID()` returns conflicting IDs. #3803
* [BUGFIX] Fix deadlock on the alerts memory store. #3715
* [BUGFIX] Fix `amtool template render` when using the default values. #3725
* [BUGFIX] Fix `webhook_url_file` for both the Discord and Microsoft Teams integrations. #3728 #3745

---------

Signed-off-by: SuperQ <[email protected]>
Signed-off-by: gotjosh <[email protected]>
Co-authored-by: gotjosh <[email protected]>
ContentType: "application/vnd.microsoft.card.adaptive",
ContentURL: nil,
Content: Content{
Schema: "http://adaptivecards.io/schemas/adaptive-card.json",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The text in desktop view is cut off and does not take up the full width of the message.
On mobile, only the title appears.
https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-format?tabs=adaptive-md%2Cdesktop%2Cconnector-html#full-width-adaptive-card
desktop_view
mobile_view

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Microsoft deprecating Teams webhooks, new "Workflows" uses incompatible schema
7 participants