pagerduty2

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPagerDuty2APIURL = "https://events.pagerduty.com/v2/enqueue"

DefaultPagerDuty2APIURL is the default URL for the v2 API

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertPayload

type AlertPayload struct {
	RoutingKey  string  `json:"routing_key"`
	EventAction string  `json:"event_action"`
	DedupKey    string  `json:"dedup_key"`
	Payload     *PDCEF  `json:"payload"`
	Images      []Image `json:"images"`
	Links       []Link  `json:"links"`
	Client      string  `json:"client"`
	ClientURL   string  `json:"client_url"`
}

AlertPayload is the default struct to send an element through to PagerDuty

type Config

type Config struct {
	// Whether PagerDuty integration is enabled.
	Enabled bool `toml:"enabled" override:"enabled"`
	// The PagerDuty API URL, should not need to be changed.
	URL string `toml:"url" override:"url"`
	// The PagerDuty routing key, this is associated with an Event v2 API integration service.
	RoutingKey string `toml:"routing-key" override:"routing-key,redact"`
	// Whether every alert should automatically go to PagerDuty
	Global bool `toml:"global" override:"global"`
}

Config is the default struct for the PagerDuty v2 plugin

func NewConfig

func NewConfig() Config

NewConfig returns a new instance of the primary config struct for PagerDuty

func (Config) Validate

func (c Config) Validate() error

Validate is a bound method that checks/confirms whether the attached configuration is valid

type Diagnostic

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

Diagnostic defines the interface of a diagnostic event

type HandlerConfig

type HandlerConfig struct {
	// The routing key to use for the alert.
	// Defaults to the value in the configuration if empty.
	RoutingKey string         `mapstructure:"routing-key"`
	Links      []LinkTemplate `mapstructure:"links"`
}

HandlerConfig defines the high-level struct required to connect to PagerDuty

type Image

type Image struct {
	Src  string `json:"src"`
	Href string `json:"href"`
	Alt  string `json:"alt"`
}

Image is the struct of elements for an image in the payload

type Link struct {
	Href string `json:"href"`
	Text string `json:"text"`
}

Link is the struct of elements for a link in the payload

type LinkTemplate added in v1.5.2

type LinkTemplate struct {
	Href string `mapstructure:"href" json:"href"`
	Text string `mapstructure:"text" json:"text"`
	// contains filtered or unexported fields
}

type PDCEF

type PDCEF struct {
	Summary       string                 `json:"summary"`
	Source        string                 `json:"source"`
	Severity      string                 `json:"severity"`
	Timestamp     string                 `json:"timestamp"`
	Class         string                 `json:"class"`
	Component     string                 `json:"component"`
	Group         string                 `json:"group"`
	CustomDetails map[string]interface{} `json:"custom_details"`
}

PDCEF is the PagerDuty - Common Event Format (PD-CEF) as outlined in the v2 API https://v2.developer.pagerduty.com/docs/events-api-v2 https://support.pagerduty.com/docs/pd-cef

API entry point is now https://events.pagerduty.com/v2/enqueue

type Service

type Service struct {
	HTTPDService interface {
		URL() string
	}
	// contains filtered or unexported fields
}

Service is the default struct for the HTTP service

func NewService

func NewService(c Config, d Diagnostic) *Service

NewService returns a newly instantiated Service

func (*Service) Alert

func (s *Service) Alert(routingKey string, links []LinkTemplate, alertID, desc string, level alert.Level, timestamp time.Time, data alert.EventData) error

Alert is a bound method of the Service struct that processes a given alert to PagerDuty

The req headers are now required with the API v2: https://v2.developer.pagerduty.com/docs/migrating-to-api-v2

func (*Service) Close

func (s *Service) Close() error

Close is a bound method of the Service struct

func (*Service) Global

func (s *Service) Global() bool

Global is a bound method of the Service struct, returns whether the Service configuration is global

func (*Service) Handler

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

Handler is a bound method to the Service struct that returns the appropriate alert handler for PagerDuty

func (*Service) Open

func (s *Service) Open() error

Open is a bound method of the Service struct

func (*Service) Test

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

Test is a bound method of the Service struct that handles testing the Alert function

func (*Service) TestOptions

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

TestOptions returns optional values for the test harness

func (*Service) Update

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

Update is a bound method of the Service struct, handles updates to the existing service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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