From 4e57e98b764b9dc9e1574a26cdf5e12e92175a4a Mon Sep 17 00:00:00 2001 From: Yuri Tseretyan Date: Tue, 11 Feb 2025 17:16:53 -0500 Subject: [PATCH] create configuration --- .../channels_config/available_channels.go | 152 +++++++++++++++++- 1 file changed, 151 insertions(+), 1 deletion(-) diff --git a/pkg/services/ngalert/notifier/channels_config/available_channels.go b/pkg/services/ngalert/notifier/channels_config/available_channels.go index e1748a7550b..404496e6dd1 100644 --- a/pkg/services/ngalert/notifier/channels_config/available_channels.go +++ b/pkg/services/ngalert/notifier/channels_config/available_channels.go @@ -5,6 +5,7 @@ import ( "os" "strings" + "github.com/grafana/alerting/receivers/jira" alertingMqtt "github.com/grafana/alerting/receivers/mqtt" alertingOpsgenie "github.com/grafana/alerting/receivers/opsgenie" alertingPagerduty "github.com/grafana/alerting/receivers/pagerduty" @@ -365,7 +366,7 @@ func GetAvailableNotifiers() []*NotifierPlugin { InputType: InputTypeText, PropertyName: "details", }, - { //New in 11.1 + { // New in 11.1 Label: "URL", Description: "The URL to send API requests to", Element: ElementTypeInput, @@ -1708,6 +1709,155 @@ func GetAvailableNotifiers() []*NotifierPlugin { }, }, }, + { // Since Grafana 11.6 + Type: "jira", + Name: "Jira", + Description: "Creates Jira issues from alerts", + Heading: "Jira settings", + Options: []NotifierOption{ + { + Label: "API URL of Jira instance, including version of API", + Element: ElementTypeInput, + InputType: InputTypeText, + Placeholder: "https://grafana.atlassian.net/rest/api/3", + PropertyName: "api_url", + Description: "Supported v2 or v3 APIs, e.g. https://grafana.atlassian.net/rest/api/3", + Required: true, + }, + { + Label: "HTTP Basic Authentication - Username", + Element: ElementTypeInput, + InputType: InputTypeText, + PropertyName: "user", + Description: "Username to use for Jira authentication. Usually, it should be your email address.", + Secure: true, + Required: false, + }, + { + Label: "HTTP Basic Authentication - Password", + Element: ElementTypeInput, + InputType: InputTypePassword, + PropertyName: "password", + // Go to https://id.atlassian.com/manage-profile/security/api-tokens to obtain a token. + Description: "Password to use for Jira authentication.", + Secure: true, + Required: false, + }, + { + Label: "Authorization Header - Personal Access Token", + Element: ElementTypeInput, + InputType: InputTypePassword, + PropertyName: "api_token", + // Go to https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html for how to obtain a token. + Description: "Personal Access Token that is used as a bearer authorization header.", + Secure: true, + Required: false, + }, + { + Label: "Project Key", + Description: "The project key where issues are created", + Element: ElementTypeInput, + InputType: InputTypeText, + Placeholder: "Grafana", + PropertyName: "project", + Required: true, + }, + { + Label: "Issue Type", + Description: "The type of the Jira issue (e.g., Bug, Task, Story). You can use templates to customize this field.", + Element: ElementTypeInput, + InputType: InputTypeText, + Placeholder: "Task", + Required: true, + PropertyName: "issue_type", + }, + { + Label: "Summary", + Description: fmt.Sprintf("The summary of the Jira issue. You can use templates to customize this field. Maximum length is %d characters. Otheriwse, the text will be truncated", jira.MaxSummaryLenRunes), + Element: ElementTypeInput, + InputType: InputTypeText, + Placeholder: jira.DefaultSummary, + PropertyName: "summary", + }, + { + Label: "Description", + Description: fmt.Sprintf("The description of the Jira issue. You can use templates to customize this field. Maximum length is %d characters. Otheriwse, the text will be truncated", jira.MaxDescriptionLenRunes), + Element: ElementTypeTextArea, + InputType: InputTypeText, + Placeholder: jira.DefaultDescription, + PropertyName: "description", + }, + { + Label: "Labels", + Description: "Labels to assign to the Jira issue. You can use templates to customize this field.", + Element: ElementSubformArray, + InputType: InputTypeText, + Placeholder: "", + PropertyName: "labels", + }, + { + Label: "Priority", + Description: "The priority of the Jira issue (e.g., High, Medium, Low). You can use templates to customize this field.", + Element: ElementTypeInput, + InputType: InputTypeText, + Placeholder: jira.DefaultPriority, + PropertyName: "priority", + Required: false, + }, + { + Label: "Resolve Transition", + Description: `Name of the workflow transition to resolve an issue. The target status must have the category "done". If not set, the issue will not be resolved.`, + Element: ElementTypeInput, + InputType: InputTypeText, + Placeholder: "", + PropertyName: "resolve_transition", + Required: false, + }, + { + Label: "Reopen Transition", + Description: `Name of the workflow transition to resolve an issue. The target status must not have the category "done". If not set, the issue will not be reopened.`, + Element: ElementTypeInput, + InputType: InputTypeText, + Placeholder: "", + PropertyName: "reopen_transition", + Required: false, + }, + { + Label: "Reopen Duration", + Description: "Reopen the issue when it is not older than this value in minutes. Otherwise, create a new issue.", + Element: ElementTypeInput, + InputType: InputTypeText, + Placeholder: "10m", + PropertyName: "reopen_duration", + }, + { + Label: "\"Won't fix\" Transition", + Description: `If reopen transition is defined, ignore issues with that resolution`, + Element: ElementTypeInput, + InputType: InputTypeText, + Placeholder: "", + PropertyName: "wont_fix_resolution", + Required: false, + }, + { + Label: "Custom field ID for deduplication", + Description: "Id of custom field where the deduplication key should be stored. Otherwise, it will be added to labels in format 'ALERT($KEY)'", + Element: ElementTypeInput, + InputType: InputTypeText, + Placeholder: "10000", + ValidationRule: "^[0-9]+$", + PropertyName: "dedup_key_field", + }, + { + Label: "Custom Field Data", + Description: "Custom field data to set on the Jira issue.", + Element: ElementTypeKeyValueMap, + InputType: InputTypeText, + Placeholder: "", + PropertyName: "fields", + }, + }, + }, } }