Safe Haskell | None |
---|---|
Language | Haskell2010 |
The PagerDuty event integration API is how you would add PagerDuty's advanced alerting functionality to any system that can make an HTTP API call. You can now add phone, SMS and email alerting to your monitoring tools, ticketing systems and custom software.
The API was designed to allow you to easily integrate a monitoring system with a Service in PagerDuty. Monitoring systems generally send out events when problems are detected and when these problems have been resolved (fixed). Some more advanced systems also understand the concept of acknowledgements: problems can be acknowledged by an engineer to signal he or she is working on fixing the issue.
Since monitoring systems emit events, the API is based around accepting events. Incoming events (sent via the API) are routed to a PagerDuty service and processed. They may result in a new incident being created, or an existing incident being acknowledged or resolved.
The same event-based API can also be used to integrate a PagerDuty service with ticketing systems and various other software tools.
See: http://developer.pagerduty.com/documentation/integration/events
- submit :: MonadIO m => Manager -> Event -> m (Either Error Response)
- submitWith :: MonadIO m => Manager -> Logger -> Event -> m (Either Error Response)
- data Trigger
- trigger :: ServiceKey -> IncidentKey -> Text -> Event
- client :: Lens' Trigger (Maybe Text)
- clientUrl :: Lens' Trigger (Maybe Text)
- type Acknowledge = Generic
- acknowledge :: ServiceKey -> IncidentKey -> Event
- type Resolve = Generic
- resolve :: ServiceKey -> IncidentKey -> Event
- class HasServiceKey s a | s -> a where
- serviceKey :: Lens' s a
- class HasIncidentKey s a | s -> a where
- incidentKey :: Lens' s a
- class HasDescription s a | s -> a where
- description :: Lens' s a
- class HasDetails s a | s -> a where
- details :: Lens' s a
- data Event
- _Trigger :: Prism' Event Trigger
- _Acknowledge :: Prism' Event Generic
- _Resolve :: Prism' Event Generic
- data Response
- rsStatus :: Lens' Response Text
- rsMessage :: Lens' Response Text
- rsIncidentKey :: Lens' Response IncidentKey
- data Generic
- data Env s
- envDomain :: forall s. Lens' (Env s) SubDomain
- envAuth :: forall s s'. Lens (Env s) (Env s') (Auth s) (Auth s')
- envManager :: forall s. Lens' (Env s) Manager
- envLogger :: forall s. Lens' (Env s) Logger
- data Logger
- debug :: MonadIO m => Logger -> Text -> m ()
- class Paginate a
- data Request a s b
- data Error
- _Internal :: Prism' Error Text
- _Integration :: Prism' Error IntegrationError
- _REST :: Prism' Error RESTError
- class HasMessage s a | s -> a where
- message :: Lens' s a
- class HasErrors s a | s -> a where
- errors :: Lens' s a
- data IntegrationError
- status :: Lens' IntegrationError Text
- data RESTError
- data Code
- code :: Lens' RESTError Code
- description :: Code -> Text
- data Security
- data Auth a where
- AuthBasic :: ByteString -> ByteString -> Auth Basic
- AuthToken :: ByteString -> Auth Token
- data Key a
- mkKey :: Text -> Key a
- type ServiceKey = Key "service"
- type IncidentKey = Key "incident"
- data Id a
- mkId :: Text -> Id a
- type AlertId = Id "alert"
- type ContactId = Id "contact"
- type EmailFilterId = Id "email-filter"
- type EscalationPolicyId = Id "escalation-policy"
- type EscalationRuleId = Id "escalation-rule"
- type IncidentId = Id "incident"
- type LogEntryId = Id "log-entry"
- type NoteId = Id "note"
- type NotificationRuleId = Id "notification-rule"
- type OverrideId = Id "schedule-override"
- type RequesterId = Id "requester"
- type ScheduleId = Id "schedule"
- type ServiceId = Id "service"
- type UserId = Id "user"
- type VendorId = Id "vendor"
- type WebhookId = Id "webhook"
- type WindowId = Id "maintenance-window"
- data SubDomain
- mkSubDomain :: ByteString -> SubDomain
- data Address
- mkAddress :: Text -> Address
- data Empty = Empty
Sending events
submit :: MonadIO m => Manager -> Event -> m (Either Error Response)
Send an event to the integration API.
Trigger
data Trigger
Eq Trigger | |
Show Trigger | |
ToJSON Trigger | |
FromJSON Trigger | |
HasDescription Trigger Text | |
HasIncidentKey Trigger IncidentKey | |
HasServiceKey Trigger ServiceKey | |
HasDetails Trigger (Maybe Object) |
:: ServiceKey | |
-> IncidentKey | |
-> Text | |
-> Event |
Your monitoring tools should send PagerDuty a trigger event to report a new or ongoing problem. When PagerDuty receives a trigger event, it will either open a new incident, or add a new trigger log entry to an existing incident, depending on the provided incident_key.
client :: Lens' Trigger (Maybe Text)
The name of the monitoring client that is triggering this event.
clientUrl :: Lens' Trigger (Maybe Text)
The URL of the monitoring client that is triggering this event.
Acknowledge
type Acknowledge = Generic
Acknowledge events cause the referenced incident to enter the acknowledged state.
While an incident is acknowledged, it won't generate any additional notifications, even if it receives new trigger events. Your monitoring tools should send PagerDuty an acknowledge event when they know someone is presently working on the problem.
Resolve
Resolve events cause the referenced incident to enter the resolved state.
Once an incident is resolved, it won't generate any additional notifications. New trigger events with the same incident_key as a resolved incident won't re-open the incident. Instead, a new incident will be created. Your monitoring tools should send PagerDuty a resolve event when the problem that caused the initial trigger event has been fixed.
Fields
class HasServiceKey s a | s -> a where
serviceKey :: Lens' s a
The GUID of one of your "Generic API" services. This is the "service key" listed on a Generic API's service detail page.
class HasIncidentKey s a | s -> a where
incidentKey :: Lens' s a
Identifies the incident to which this trigger event should be applied. If there's no open (i.e. unresolved) incident with this key, a new one will be created. If there's already an open incident with a matching key, this event will be appended to that incident's log. The event key provides an easy way to "de-dup" problem reports. If this field isn't provided, PagerDuty will automatically open a new incident with a unique key.
class HasDescription s a | s -> a where
description :: Lens' s a
A short description of the problem that led to this trigger. This field (or a truncated version) will be used when generating phone calls, SMS messages and alert emails. It will also appear on the incidents tables in the PagerDuty UI. The maximum length is 1024 characters.
HasDescription Trigger Text | |
HasDescription Generic (Maybe Text) |
class HasDetails s a | s -> a where
details :: Lens' s a
An arbitrary JSON object containing any data you'd like included in the incident log.
HasDetails Trigger (Maybe Object) | |
HasDetails Generic (Maybe Object) | |
HasDetails Event (Maybe Object) |
Types
data Event
Trigger Trigger | See: |
Acknowledge Generic | See: |
Resolve Generic | See: |
Eq Event | |
Show Event | |
ToJSON Event | |
HasIncidentKey Event IncidentKey | |
HasServiceKey Event ServiceKey | |
HasDetails Event (Maybe Object) |
_Acknowledge :: Prism' Event Generic
rsIncidentKey :: Lens' Response IncidentKey
The key of the incident that will be affected by the request.
data Generic
Eq Generic | |
Show Generic | |
ToJSON Generic | |
FromJSON Generic | |
HasIncidentKey Generic IncidentKey | |
HasServiceKey Generic ServiceKey | |
HasDetails Generic (Maybe Object) | |
HasDescription Generic (Maybe Text) |
Configuration
Environment
data Env s
The environment containing the parameters required to make PagerDuty requests.
Monad m => MonadReader (Env s) (PagerDutyT s m) |
envManager :: forall s. Lens' (Env s) Manager
Logging
debug :: MonadIO m => Logger -> Text -> m ()
Log a message using the debug logger, or if none is specified noop.
Types
Requests
class Paginate a
Exists primarily to obtain a constraint for the paginate
function.
data Request a s b
ToJSON (Request a s b) | |
(QueryLike a, ToJSON a, HasUserInfo a) => HasUserInfo (Request a s b) | |
(QueryLike a, ToJSON a, HasEmailFilterInfo a) => HasEmailFilterInfo (Request a s b) |
Errors
data Error
Eq Error | |
Show Error | |
FromJSON Error | |
HasMessage Error Text | |
Monad m => MonadError Error (PagerDutyT s m) |
_Integration :: Prism' Error IntegrationError
Messages
class HasMessage s a | s -> a where
message :: Lens' s a
A short human-readable message describing the error.
HasMessage IntegrationError Text | |
HasMessage RESTError Text | |
HasMessage Error Text |
Fields
class HasErrors s a | s -> a where
errors :: Lens' s a
A list of human-readable reasons for the error. These values, and even their format, are subject to change.
HasErrors IntegrationError [Text] | |
HasErrors RESTError [Text] |
Integration
data IntegrationError
Eq IntegrationError | |
Show IntegrationError | |
ToJSON IntegrationError | |
FromJSON IntegrationError | |
HasMessage IntegrationError Text | |
HasErrors IntegrationError [Text] |
status :: Lens' IntegrationError Text
REST
data RESTError
In the case of an error, the PagerDuty error code can give further details on the nature of the error.
See: description
description :: Code -> Text
Authentication
data Auth a where
AuthBasic :: ByteString -> ByteString -> Auth Basic | |
AuthToken :: ByteString -> Auth Token |
Keys
data Key a
HasIncidentKey Trigger IncidentKey | |
HasIncidentKey Generic IncidentKey | |
HasIncidentKey Event IncidentKey | |
HasServiceKey Trigger ServiceKey | |
HasServiceKey Generic ServiceKey | |
HasServiceKey Event ServiceKey | |
Eq (Key a) | |
Show (Key a) | |
IsString (Key a) | |
ToJSON (Key a) | |
FromJSON (Key a) | |
ToByteString (Key a) | |
QueryValueLike (Key a) |
Aliases
type ServiceKey = Key "service"
type IncidentKey = Key "incident"
Identifiers
data Id a
Aliases
type EmailFilterId = Id "email-filter"
type EscalationPolicyId = Id "escalation-policy"
type EscalationRuleId = Id "escalation-rule"
type IncidentId = Id "incident"
type LogEntryId = Id "log-entry"
type NotificationRuleId = Id "notification-rule"
type OverrideId = Id "schedule-override"
type RequesterId = Id "requester"
type ScheduleId = Id "schedule"
SubDomain
mkSubDomain :: ByteString -> SubDomain
Address
data Address