alerta

package
v1.7.6 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 17 Imported by: 72

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Whether Alerta integration is enabled.
	Enabled bool `toml:"enabled" override:"enabled"`
	// The Alerta URL.
	URL string `toml:"url" override:"url"`
	// Whether to skip the tls verification of the alerta host
	InsecureSkipVerify bool `toml:"insecure-skip-verify" override:"insecure-skip-verify"`
	// The authentication token for this notification, can be overridden per alert.
	Token string `toml:"token" override:"token,redact"`
	// The prefix for the Authentication field where the token is stored
	// This defaults to Bearer but you may need to set this to "Key" for older versions of alerta
	TokenPrefix string `toml:"token-prefix" override:"token-prefix"`
	// The environment in which to raise the alert.
	Environment string `toml:"environment" override:"environment"`
	// The origin of the alert.
	Origin string `toml:"origin" override:"origin"`
	// Optional timeout, can be overridden per alert.
	Timeout toml.Duration `toml:"timeout" override:"timeout"`
}

func NewConfig

func NewConfig() Config

func (Config) Validate added in v1.1.0

func (c Config) Validate() error

type Diagnostic added in v1.4.0

type Diagnostic interface {
	WithContext(ctx ...keyvalue.T) Diagnostic
	TemplateError(err error, kv keyvalue.T)
	Error(msg string, err error)
}

type HandlerConfig added in v1.2.0

type HandlerConfig struct {
	// Alerta authentication token.
	// If empty uses the token from the configuration.
	Token string `mapstructure:"token"`

	// Alerta authentication token prefix.
	// If empty uses Bearer.
	TokenPrefix string `mapstructure:"token-prefix"`

	// Alerta resource.
	// Can be a template and has access to the same data as the AlertNode.Details property.
	// Default: {{ .Name }}
	Resource string `mapstructure:"resource"`

	// Alerta event.
	// Can be a template and has access to the same data as the idInfo property.
	// Default: {{ .ID }}
	Event string `mapstructure:"event"`

	// Alerta environment.
	// Can be a template and has access to the same data as the AlertNode.Details property.
	// Defaut is set from the configuration.
	Environment string `mapstructure:"environment"`

	// Alerta group.
	// Can be a template and has access to the same data as the AlertNode.Details property.
	// Default: {{ .Group }}
	Group string `mapstructure:"group"`

	// Alerta value.
	// Can be a template and has access to the same data as the AlertNode.Details property.
	// Default is an empty string.
	Value string `mapstructure:"value"`

	// Alerta origin.
	// If empty uses the origin from the configuration.
	Origin string `mapstructure:"origin"`

	// List of effected Services
	Service []string `mapstructure:"service"`

	// List of correlated events
	Correlate []string `mapstructure:"correlate"`

	// Map of alert attributes
	Attributes map[string]interface{} `mapstructure:"attributes"`

	// Alerta timeout.
	// Default: 24h
	Timeout time.Duration `mapstructure:"timeout"`
}

type Service

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

func NewService

func NewService(c Config, d Diagnostic) *Service

func (*Service) Alert

func (s *Service) Alert(token, tokenPrefix, resource, event, environment, severity, group, value, message, origin string, service []string, correlate []string, attributes map[string]interface{}, timeout time.Duration, tags map[string]string, data models.Result) error

func (*Service) Close

func (s *Service) Close() error

func (*Service) DefaultHandlerConfig added in v1.2.0

func (s *Service) DefaultHandlerConfig() HandlerConfig

func (*Service) Handler added in v1.2.0

func (s *Service) Handler(c HandlerConfig, ctx ...keyvalue.T) (alert.Handler, error)

func (*Service) Open

func (s *Service) Open() error

func (*Service) Test added in v1.1.0

func (s *Service) Test(options interface{}) error

func (*Service) TestOptions added in v1.1.0

func (s *Service) TestOptions() interface{}

func (*Service) Update added in v1.1.0

func (s *Service) Update(newConfig []interface{}) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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