A fluent ColdFusion interface for firing PagerDuty events
PagerDuty is an incedent-aggregation service that consolidates alerts around a single manageable interface. Leveraging PagerDuty within DonorDrive give us real-time alerts when an incident occurs.
The pagerduty
package assumes that it will reside in a lib
directory under the web root, or mapped in the consuming application.
The library comprises of a PagerDutyEvent
component, and an IPagerDutyClient
interface.
pde = new lib.pagerduty.PagerDutyEvent(new MXUnitPagerDutyClient(), "MXUNIT_TEST_EVENT")
.setComponent("MXUnit")
.setCustomDetails({ "foo": "bar" })
.setGroup("coldfusion")
.setSeverity("info")
.setSource("try.donordrive.com")
.setSummary("PagerDuty Test from MX Unit (Trigger)")
.setType("test");
result = pde.trigger();
The constructor takes two arguments: an implementation of IPagerDutyClient
(see below) and an eventKey
. The eventKey
sets the dedup_key
in the underlying API call.
Reference: https://v2.developer.pagerduty.com/docs/send-an-event-events-api-v2
Properties are available via get*
and set*
.
Property | API Equivalent |
---|---|
component |
payload.component |
customDetails |
payload.custom_details |
severity (required) |
payload.severity |
summary (required) |
payload.summary |
timestamp |
payload.timestamp |
type |
payload.class |
Images may be appended to the event by calling PagerDutyEvent.addImage()
Links may be attached to the event by calling PagerDutyEvent.addLink()
Components implementing IPagerDutyClient
must have the following 3 methods:
getApplicationName()
: Used to set thepayload.group
field in the underlying API call.getApplicationURL()
: Setspayload.source
getPagerDutyKey()
: Setsrouting_key