v1

package
v0.0.0-release-12.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version = schema.V1

	SendTags    = "tags"
	SendDetails = "details"
	SendBoth    = "both"

	DefaultAlertsURL = "https://api.opsgenie.com/v2/alerts"
)
View Source
const FullValidConfigForTesting = `` /* 416-byte string literal not displayed */

FullValidConfigForTesting is a string representation of a JSON object that contains all fields supported by the notifier Config. It can be used without secrets.

View Source
const FullValidSecretsForTesting = `{
	"apiKey": "test-secret-api-key"
}`

FullValidSecretsForTesting is a string representation of JSON object that contains all fields that can be overridden from secrets

Variables

View Source
var Schema = schema.IntegrationSchemaVersion{
	Version:    Version,
	CanCreate:  true,
	Deprecated: false,
	Options: []schema.Field{
		{
			Label:        "API Key",
			Element:      schema.ElementTypeInput,
			InputType:    schema.InputTypeText,
			Placeholder:  "OpsGenie API Key",
			PropertyName: "apiKey",
			Required:     true,
			Secure:       true,
		},
		{
			Label:        "Alert API URL",
			Element:      schema.ElementTypeInput,
			InputType:    schema.InputTypeText,
			Placeholder:  "https://api.opsgenie.com/v2/alerts",
			PropertyName: "apiUrl",
			Required:     true,
			Protected:    true,
		},
		{
			Label:        "Message",
			Description:  "Alert text limited to 130 characters.",
			Element:      schema.ElementTypeTextArea,
			InputType:    schema.InputTypeText,
			Placeholder:  templates.DefaultMessageTitleEmbed,
			PropertyName: "message",
		},
		{
			Label:        "Description",
			Description:  "A description of the incident.",
			Element:      schema.ElementTypeTextArea,
			PropertyName: "description",
		},
		{
			Label:        "Auto close incidents",
			Element:      schema.ElementTypeCheckbox,
			Description:  "Automatically close alerts in OpsGenie once the alert goes back to ok.",
			PropertyName: "autoClose",
		}, {
			Label:        "Override priority",
			Element:      schema.ElementTypeCheckbox,
			Description:  "Allow the alert priority to be set using the og_priority label.",
			PropertyName: "overridePriority",
		},
		{
			Label:   "Send notification tags as",
			Element: schema.ElementTypeSelect,
			SelectOptions: []schema.SelectOption{
				{
					Value: SendTags,
					Label: "Tags",
				},
				{
					Value: SendDetails,
					Label: "Extra Properties",
				},
				{
					Value: SendBoth,
					Label: "Tags & Extra Properties",
				},
			},
			Description:  "Send the common annotations to Opsgenie as either Extra Properties, Tags or both",
			PropertyName: "sendTagsAs",
		},

		{
			Label:        "Responders",
			PropertyName: "responders",
			Description:  "If the API key belongs to a team, this field is ignored.",
			Element:      schema.ElementSubformArray,
			SubformOptions: []schema.Field{
				{
					Label:        "Type",
					Description:  fmt.Sprintf("%s or a template", strings.Join(SupportedResponderTypes, ", ")),
					Element:      schema.ElementTypeInput,
					Required:     true,
					PropertyName: "type",
				},
				{
					Label:        "Name",
					Element:      schema.ElementTypeInput,
					Description:  "Name of the responder. Must be specified if ID and Username are empty or if the type is 'teams'.",
					PropertyName: "name",
				},
				{
					Label:        "ID",
					Element:      schema.ElementTypeInput,
					Description:  "ID of the responder. Must be specified if name and Username are empty.",
					PropertyName: "id",
				},
				{
					Label:        "Username",
					Element:      schema.ElementTypeInput,
					Description:  "User name of the responder. Must be specified if ID and Name are empty.",
					PropertyName: "username",
				},
			},
		},
	},
}
View Source
var SupportedResponderTypes = []string{"team", "teams", "user", "escalation", "schedule"}
View Source
var (
	ValidPriorities = map[string]bool{"P1": true, "P2": true, "P3": true, "P4": true, "P5": true}
)

Functions

This section is empty.

Types

type Config

type Config struct {
	APIKey           string
	APIUrl           string
	Message          string
	Description      string
	AutoClose        bool
	OverridePriority bool
	SendTagsAs       string
	Responders       []MessageResponder
}

func NewConfig

func NewConfig(jsonData json.RawMessage, decryptFn receivers.DecryptFunc) (Config, error)

type MessageResponder

type MessageResponder struct {
	ID       string `json:"id,omitempty" yaml:"id,omitempty"`
	Name     string `json:"name,omitempty" yaml:"name,omitempty"`
	Username string `json:"username,omitempty" yaml:"username,omitempty"`
	Type     string `json:"type" yaml:"type"` // team, user, escalation, schedule etc.
}

type Notifier

type Notifier struct {
	*receivers.Base
	// contains filtered or unexported fields
}

Notifier is responsible for sending alert notifications to Opsgenie. It interacts with OpsGenie platform using Alert API, using endpoints "Create Alert" (https://docs.opsgenie.com/docs/alert-api#create-alert) and "Close Alert" (https://docs.opsgenie.com/docs/alert-api#close-alert) It creates OpsGenie alerts with alias that is a hash of the aggregation group, which is immutable during the lifetime of the group. This alias is used to close alerts when the following conditions are met: 1. Setting Config.AutoClose is set to `true` 2. Setting DisableResolveMessage is set to false. 3. All alerts in the aggregation group are resolved.

func New

func New(cfg Config, meta receivers.Metadata, template *templates.Template, sender receivers.WebhookSender, images images.Provider, logger log.Logger) *Notifier

func (*Notifier) Notify

func (on *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

Notify sends an alert notification to Opsgenie

func (*Notifier) SendResolved

func (on *Notifier) SendResolved() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址