Documentation ¶
Index ¶
- Constants
- type AlertPayload
- type Config
- type Diagnostic
- type HandlerConfig
- type Image
- type Link
- type PDCEF
- type Service
- func (s *Service) Alert(serviceKey, alertID, desc string, level alert.Level, timestamp time.Time, ...) error
- func (s *Service) Close() error
- func (s *Service) Global() bool
- func (s *Service) Handler(c HandlerConfig, ctx ...keyvalue.T) alert.Handler
- func (s *Service) Open() error
- func (s *Service) Test(options interface{}) error
- func (s *Service) TestOptions() interface{}
- func (s *Service) Update(newConfig []interface{}) error
Constants ¶
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
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"` }
HandlerConfig defines the high-level struct required to connect to PagerDuty
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(serviceKey, 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) Global ¶
Global is a bound method of the Service struct, returns whether the Service configuration is global
func (*Service) Handler ¶
Handler is a bound method to the Service struct that returns the appropriate alert handler for PagerDuty
func (*Service) Test ¶
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