From 7b92849508e3c6dd2f8a4196c32c53b993ef5f9f Mon Sep 17 00:00:00 2001 From: Santiago Date: Wed, 29 Mar 2023 10:35:01 -0300 Subject: [PATCH] Alerting: Add CustomDetails field in PagerDuty contact point (#64860) * Alerting: Add CustomDetails for PagerDuty * fix default value for 'severity' from 'error' to 'critical' * minimal docs for notifiers, specifying config for PagerDuty * replace notifier -> integration * replace notifier -> integration --- .../_index.md} | 13 ++-- .../configure-integrations.md | 68 +++++++++++++++++++ .../channels_config/available_channels.go | 11 ++- .../notifier/channels_config/plugin.go | 2 + 4 files changed, 86 insertions(+), 8 deletions(-) rename docs/sources/alerting/manage-notifications/{create-contact-point.md => manage-contact-points/_index.md} (82%) create mode 100644 docs/sources/alerting/manage-notifications/manage-contact-points/configure-integrations.md diff --git a/docs/sources/alerting/manage-notifications/create-contact-point.md b/docs/sources/alerting/manage-notifications/manage-contact-points/_index.md similarity index 82% rename from docs/sources/alerting/manage-notifications/create-contact-point.md rename to docs/sources/alerting/manage-notifications/manage-contact-points/_index.md index 36122fe9968..9204d2237a1 100644 --- a/docs/sources/alerting/manage-notifications/create-contact-point.md +++ b/docs/sources/alerting/manage-notifications/manage-contact-points/_index.md @@ -1,9 +1,10 @@ --- aliases: - - ../contact-points/create-contact-point/ - - ../contact-points/delete-contact-point/ - - ../contact-points/edit-contact-point/ - - ../contact-points/test-contact-point/ + - ../../contact-points/create-contact-point/ + - ../../contact-points/delete-contact-point/ + - ../../contact-points/edit-contact-point/ + - ../../contact-points/test-contact-point/ + - ../create-contact-point/ keywords: - grafana - alerting @@ -24,10 +25,10 @@ Complete the following steps to add a contact point. 1. In the left-side menu, click **Alerts & incidents** and then **Alerting**. 1. Click **Contact points**. +1. From the **Choose Alertmanager** dropdown, select an Alertmanager. By default, **Grafana Alertmanager** is selected. 1. Click **+ Add contact point**. -1. From the **Alertmanager** dropdown, select an Alertmanager. By default, **Grafana Alertmanager** is selected. 1. In **Name**, enter a descriptive name for the contact point. -1. From **Contact point integration**, select a type and fill out mandatory fields. For example, if you choose email, enter the email addresses. Or if you choose Slack, enter the Slack channel(s) and users who should be contacted. +1. From **Integration**, select a type and fill out mandatory fields. For example, if you choose email, enter the email addresses. Or if you choose Slack, enter the Slack channel(s) and users who should be contacted. 1. Some contact point integrations, like email or webhook, have optional settings. In **Optional settings**, specify additional settings for the selected contact point integration. 1. In Notification settings, optionally select **Disable resolved message** if you do not want to be notified when an alert resolves. 1. To add another contact point integration, click **Add contact point integration** and repeat steps 6 through 8. diff --git a/docs/sources/alerting/manage-notifications/manage-contact-points/configure-integrations.md b/docs/sources/alerting/manage-notifications/manage-contact-points/configure-integrations.md new file mode 100644 index 00000000000..e462c5d20c9 --- /dev/null +++ b/docs/sources/alerting/manage-notifications/manage-contact-points/configure-integrations.md @@ -0,0 +1,68 @@ +--- +description: Configure integrations +draft: true +keywords: + - Grafana + - alerting + - guide + - notifications + - integrations + - contact points +title: Configure integrations +weight: 100 +--- + +# Configure integrations + +Configure integrations in Grafana to select your preferred communication channel for receiving notifications when your alert rules are fire. Each integration has its own configuration options and setup process. In most cases, this involves providing an API key or a Webhook URL. + +Once configured, you can use integrations as part of your contact points to receive notifications whenever your alert changes its state. In this section, we'll cover the basic steps to configure your integrations, so you can start receiving real-time alerts and stay on top of your monitoring data. + +## List of supported integrations + +| Name | Type | +| ----------------------- | ------------------------- | +| DingDing | `dingding` | +| Discord | `discord` | +| Email | `email` | +| Google Hangouts Chat | `googlechat` | +| Hipchat | `hipchat` | +| Kafka | `kafka` | +| Line | `line` | +| Microsoft Teams | `teams` | +| Opsgenie | `opsgenie` | +| [Pagerduty](#pagerduty) | `pagerduty` | +| Prometheus Alertmanager | `prometheus-alertmanager` | +| Pushover | `pushover` | +| Sensu | `sensu` | +| Sensu Go | `sensugo` | +| Slack | `slack` | +| Telegram | `telegram` | +| Threema | `threema` | +| VictorOps | `victorops` | +| Webhook | `webhook` | + +### PagerDuty + +To set up PagerDuty, provide an integration key. + +| Setting | Description | +| --------------- | ------------------------------------------------------ | +| Integration Key | Integration key for PagerDuty | +| Severity | Level for dynamic notifications, default is `critical` | +| Custom Details | Additional details about the event | + +The `CustomDetails` field is an object containing arbitrary key-value pairs. The user-defined details are merged with the ones we use by default. + +Our default values for `CustomDetails` are: + +```go +{ + "firing": `{{ template "__text_alert_list" .Alerts.Firing }}`, + "resolved": `{{ template "__text_alert_list" .Alerts.Resolved }}`, + "num_firing": `{{ .Alerts.Firing | len }}`, + "num_resolved": `{{ .Alerts.Resolved | len }}`, +} +``` + +In case of duplicate keys, the user-defined details overwrite the default ones. diff --git a/pkg/services/ngalert/notifier/channels_config/available_channels.go b/pkg/services/ngalert/notifier/channels_config/available_channels.go index 2f81aa7af18..fed29b40076 100644 --- a/pkg/services/ngalert/notifier/channels_config/available_channels.go +++ b/pkg/services/ngalert/notifier/channels_config/available_channels.go @@ -295,8 +295,8 @@ func GetAvailableNotifiers() []*NotifierPlugin { Label: "Severity", Element: ElementTypeInput, InputType: InputTypeText, - Placeholder: "error", - Description: "Severity of the event. It must be critical, error, warning, info - otherwise, the default is set which is error. You can use templates", + Placeholder: "critical", + Description: "Severity of the event. It must be critical, error, warning, info - otherwise, the default is set which is critical. You can use templates", PropertyName: "severity", }, { // New in 8.0. @@ -353,6 +353,13 @@ func GetAvailableNotifiers() []*NotifierPlugin { Placeholder: "{{ .ExternalURL }}", PropertyName: "client_url", }, + { // New in 9.5. + Label: "Details", + Description: "A set of arbitrary key/value pairs that provide further detail about the incident.", + Element: ElementTypeKeyValueMap, + InputType: InputTypeText, + PropertyName: "details", + }, }, }, { diff --git a/pkg/services/ngalert/notifier/channels_config/plugin.go b/pkg/services/ngalert/notifier/channels_config/plugin.go index aa770e0c49a..8417d304e99 100644 --- a/pkg/services/ngalert/notifier/channels_config/plugin.go +++ b/pkg/services/ngalert/notifier/channels_config/plugin.go @@ -38,6 +38,8 @@ const ( ElementTypeCheckbox = "checkbox" // ElementTypeTextArea will render a textarea ElementTypeTextArea = "textarea" + // ElementTypeKeyValueMap will render inputs to add arbitrary key-value pairs + ElementTypeKeyValueMap = "key_value_map" ) // InputType is the type of input that can be rendered in the frontend.