From bbef000202f3bde1f8f6150086686b11bc051cfc Mon Sep 17 00:00:00 2001 From: George Robinson Date: Thu, 24 Aug 2023 09:45:12 +0100 Subject: [PATCH] Alerting: Add contact point for Grafana OnCall (#73733) Add contact point for Grafana OnCall --- go.mod | 2 +- go.sum | 6 ++ .../channels_config/available_channels.go | 81 +++++++++++++++++++ 3 files changed, 88 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index ec9ef185b53..8cc66eace0f 100644 --- a/go.mod +++ b/go.mod @@ -64,7 +64,7 @@ require ( github.com/google/uuid v1.3.0 // @grafana/backend-platform github.com/google/wire v0.5.0 // @grafana/backend-platform github.com/gorilla/websocket v1.5.0 // @grafana/grafana-app-platform-squad - github.com/grafana/alerting v0.0.0-20230606080147-55b8d71c7890 // @grafana/alerting-squad-backend + github.com/grafana/alerting v0.0.0-20230824074554-e56bbccf8ed2 // @grafana/alerting-squad-backend github.com/grafana/cuetsy v0.1.10 // @grafana/grafana-as-code github.com/grafana/grafana-aws-sdk v0.19.1 // @grafana/aws-datasources github.com/grafana/grafana-azure-sdk-go v1.7.0 // @grafana/backend-platform diff --git a/go.sum b/go.sum index 97c53cd85f9..28225c553ca 100644 --- a/go.sum +++ b/go.sum @@ -1773,6 +1773,12 @@ github.com/gotestyourself/gotestyourself v1.3.0/go.mod h1:zZKM6oeNM8k+FRljX1mnzV github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= github.com/grafana/alerting v0.0.0-20230606080147-55b8d71c7890 h1:ubNIgVGX4PQ9YI1nWnt2mky3il8clWSjdo3NFSD26DQ= github.com/grafana/alerting v0.0.0-20230606080147-55b8d71c7890/go.mod h1:zEflOvMVchYhRbFb5ziXVR/JG67FOLBzQTjhHh9xaI4= +github.com/grafana/alerting v0.0.0-20230713081236-ff256e7672ca h1:rgMWoxzcKTbHATGotF2hWtgoAXbnG79pZMHq+zXm420= +github.com/grafana/alerting v0.0.0-20230713081236-ff256e7672ca/go.mod h1:zEflOvMVchYhRbFb5ziXVR/JG67FOLBzQTjhHh9xaI4= +github.com/grafana/alerting v0.0.0-20230713081622-5aa8a0630b4f h1:rSGdigHMokMwKGtXOM/kMgX7MZPV7/KFld2/6C67ZZU= +github.com/grafana/alerting v0.0.0-20230713081622-5aa8a0630b4f/go.mod h1:zEflOvMVchYhRbFb5ziXVR/JG67FOLBzQTjhHh9xaI4= +github.com/grafana/alerting v0.0.0-20230824074554-e56bbccf8ed2 h1:cXP1s24nZ3pIsImHR7hyGvY+WjQwHjIbL5E6JC/BZrA= +github.com/grafana/alerting v0.0.0-20230824074554-e56bbccf8ed2/go.mod h1:ZiGFUeBow+S+b4yBKJBQJ+iq9zSXSYphPZ/tI2wtoN0= github.com/grafana/codejen v0.0.3 h1:tAWxoTUuhgmEqxJPOLtJoxlPBbMULFwKFOcRsPRPXDw= github.com/grafana/codejen v0.0.3/go.mod h1:zmwwM/DRyQB7pfuBjTWII3CWtxcXh8LTwAYGfDfpR6s= github.com/grafana/cuetsy v0.1.10 h1:+W9/7roI8LorL+D1RJhKGdhsTZ81adrK9dHS0r7qsXs= diff --git a/pkg/services/ngalert/notifier/channels_config/available_channels.go b/pkg/services/ngalert/notifier/channels_config/available_channels.go index 2aae696be1f..fd6f080d566 100644 --- a/pkg/services/ngalert/notifier/channels_config/available_channels.go +++ b/pkg/services/ngalert/notifier/channels_config/available_channels.go @@ -408,6 +408,87 @@ func GetAvailableNotifiers() []*NotifierPlugin { }, }, }, + { + Type: "oncall", + Name: "Grafana OnCall", + Description: "Sends alerts to Grafana OnCall", + Heading: "Grafana OnCall settings", + Options: []NotifierOption{ + { + Label: "URL", + Element: ElementTypeInput, + InputType: InputTypeText, + PropertyName: "url", + Required: true, + }, + { + Label: "HTTP Method", + Element: ElementTypeSelect, + SelectOptions: []SelectOption{ + { + Value: "POST", + Label: "POST", + }, + { + Value: "PUT", + Label: "PUT", + }, + }, + PropertyName: "httpMethod", + }, + { + Label: "HTTP Basic Authentication - Username", + Element: ElementTypeInput, + InputType: InputTypeText, + PropertyName: "username", + }, + { + Label: "HTTP Basic Authentication - Password", + Element: ElementTypeInput, + InputType: InputTypePassword, + PropertyName: "password", + Secure: true, + }, + { // New in 9.1 + Label: "Authorization Header - Scheme", + Description: "Optionally provide a scheme for the Authorization Request Header. Default is Bearer.", + Element: ElementTypeInput, + InputType: InputTypeText, + PropertyName: "authorization_scheme", + Placeholder: "Bearer", + }, + { // New in 9.1 + Label: "Authorization Header - Credentials", + Description: "Credentials for the Authorization Request header. Only one of HTTP Basic Authentication or Authorization Request Header can be set.", + Element: ElementTypeInput, + InputType: InputTypeText, + PropertyName: "authorization_credentials", + Secure: true, + }, + { // New in 8.0. TODO: How to enforce only numbers? + Label: "Max Alerts", + Description: "Max alerts to include in a notification. Remaining alerts in the same batch will be ignored above this number. 0 means no limit.", + Element: ElementTypeInput, + InputType: InputTypeText, + PropertyName: "maxAlerts", + }, + { // New in 9.3. + Label: "Title", + Description: "Templated title of the message.", + Element: ElementTypeInput, + InputType: InputTypeText, + PropertyName: "title", + Placeholder: alertingTemplates.DefaultMessageTitleEmbed, + }, + { // New in 9.3. + Label: "Message", + Description: "Custom message. You can use template variables.", + Element: ElementTypeTextArea, + PropertyName: "message", + Placeholder: alertingTemplates.DefaultMessageEmbed, + }, + }, + }, { Type: "pushover", Name: "Pushover",