plugin

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: Apache-2.0, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestPlugins []Plugin

Functions

This section is empty.

Types

type AlertPayload

type AlertPayload struct {
	Summary  string
	Severity string
	Source   string
	Details  map[string]interface{}
	Time     time.Time
}

type PagerDuty

type PagerDuty struct {
	// contains filtered or unexported fields
}

func (*PagerDuty) SendAlert

func (p *PagerDuty) SendAlert(data *AlertPayload) error

SendAlert sends an alert to PagerDuty with the provided payload data. It creates a PDData struct with the provided routing key, event action and payload. It creates an HTTP POST request with the PagerDuty event URL as the endpoint and the marshaled JSON data as the request body. It sends the request using an HTTP client with a maximum of 5 retries for network errors with exponential backoff before each retry. It handles different HTTP response status codes and returns an error based on the status code(). If all retries fail, it returns an error indicating the last network error encountered.

type Plugin

type Plugin interface {
	SendAlert(data *AlertPayload) error
}

func LoadAlertPlugins

func LoadAlertPlugins(cfg config.CurioAlertingConfig) []Plugin

func NewPagerDuty

func NewPagerDuty(cfg config.PagerDutyConfig) Plugin

func NewPrometheusAlertManager

func NewPrometheusAlertManager(cfg config.PrometheusAlertManagerConfig) Plugin

func NewSlackWebhook added in v1.23.0

func NewSlackWebhook(cfg config.SlackWebhookConfig) Plugin

type PrometheusAlertManager

type PrometheusAlertManager struct {
	// contains filtered or unexported fields
}

func (*PrometheusAlertManager) SendAlert

func (p *PrometheusAlertManager) SendAlert(data *AlertPayload) error

SendAlert sends an alert to Prometheus AlertManager with the provided payload data. API reference: https://raw.githubusercontent.com/prometheus/alertmanager/main/api/v2/openapi.yaml

type SlackWebhook added in v1.23.0

type SlackWebhook struct {
	// contains filtered or unexported fields
}

func (*SlackWebhook) SendAlert added in v1.23.0

func (s *SlackWebhook) SendAlert(data *AlertPayload) error

SendAlert sends an alert to SlackWebHook with the provided payload data. It creates a payload struct with the provided data. It creates an HTTP POST request with the SlackWebHook URL as the endpoint and the marshaled JSON data as the request body. It sends the request using an HTTP client with a maximum of 5 retries for network errors with exponential backoff before each retry. It handles different HTTP response status codes and returns an error based on the status code(). If all retries fail, it returns an error indicating the last network error encountered.

Jump to

Keyboard shortcuts

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