From 739e6c75a6af774e2c11b92ebdba1473376a86d6 Mon Sep 17 00:00:00 2001 From: Rahul Chordiya Date: Sun, 5 May 2024 04:54:25 +0530 Subject: [PATCH] fix(alerting): Make Microsoft Teams title customizable (#731) * Teams Custom Title * Update README.md * Small adjustment --------- Co-authored-by: TwiN --- README.md | 17 +++++++++-------- alerting/provider/teams/teams.go | 8 +++++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9f320e9b..90409b86 100644 --- a/README.md +++ b/README.md @@ -1133,14 +1133,15 @@ Here's an example of what the notifications look like: #### Configuring Teams alerts -| Parameter | Description | Default | -|:-----------------------------------------|:-------------------------------------------------------------------------------------------|:--------------| -| `alerting.teams` | Configuration for alerts of type `teams` | `{}` | -| `alerting.teams.webhook-url` | Teams Webhook URL | Required `""` | -| `alerting.teams.default-alert` | Default alert configuration.
See [Setting a default alert](#setting-a-default-alert) | N/A | -| `alerting.teams.overrides` | List of overrides that may be prioritized over the default configuration | `[]` | -| `alerting.teams.overrides[].group` | Endpoint group for which the configuration will be overridden by this configuration | `""` | -| `alerting.teams.overrides[].webhook-url` | Teams Webhook URL | `""` | +| Parameter | Description | Default | +|:-----------------------------------------|:-------------------------------------------------------------------------------------------|:--------------------| +| `alerting.teams` | Configuration for alerts of type `teams` | `{}` | +| `alerting.teams.webhook-url` | Teams Webhook URL | Required `""` | +| `alerting.teams.default-alert` | Default alert configuration.
See [Setting a default alert](#setting-a-default-alert) | N/A | +| `alerting.teams.overrides` | List of overrides that may be prioritized over the default configuration | `[]` | +| `alerting.teams.title` | Title of the notification | `"🚨 Gatus"` | +| `alerting.teams.overrides[].group` | Endpoint group for which the configuration will be overridden by this configuration | `""` | +| `alerting.teams.overrides[].webhook-url` | Teams Webhook URL | `""` | ```yaml alerting: diff --git a/alerting/provider/teams/teams.go b/alerting/provider/teams/teams.go index 569689bc..3dcd1812 100644 --- a/alerting/provider/teams/teams.go +++ b/alerting/provider/teams/teams.go @@ -21,6 +21,9 @@ type AlertProvider struct { // Overrides is a list of Override that may be prioritized over the default configuration Overrides []Override `yaml:"overrides,omitempty"` + + // Title is the title of the message that will be sent + Title string `yaml:"title,omitempty"` } // Override is a case under which the default integration is overridden @@ -105,9 +108,12 @@ func (provider *AlertProvider) buildRequestBody(endpoint *core.Endpoint, alert * Type: "MessageCard", Context: "http://schema.org/extensions", ThemeColor: color, - Title: "🚨 Gatus", + Title: provider.Title, Text: message + description, } + if len(body.Title) == 0 { + body.Title = "🚨 Gatus" + } if len(formattedConditionResults) > 0 { body.Sections = append(body.Sections, Section{ ActivityTitle: "Condition results",