@ceejbot/pagerduty-trigger
trigger a pagerduty alert
Last updated 4 years ago by ceejbot .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @ceejbot/pagerduty-trigger 
SYNC missed versions from official npm registry.

pagerduty-trigger

npm install pagerduty-trigger

A small module that allows you to trigger and resolve a PagerDuty alerts.

Usage

Set two environment variables:

export PAGER_DUTY_SERVICE=your-service-id
export PAGER_DUTY_API_KEY=an-api-key-with-write-perms

You can then trigger an alert like this:

var trigger = require('pagerduty-trigger');
trigger('Trouble at mill!', function(err, incidentID) {
    console.log('incident created with id ' + incidentID);
});

Resolve the same incident like this:

var resolve = require('pagerduty-trigger').resolve;
resolve(incidentID, function(err, response) {
    console.log('we have now resolved ' + incidentID);
});

API

pagerduty-trigger takes a string as the first argument, representing the description.

  triggerAlert("Your description!", function(err, incident_key) {
  //your code here
  });

pagerduty-trigger can also take an object as the first argument.

var event = {
   "description": "Your description",
   "contexts":[
    {
      "type": "link",
      "href": "http://acme.pagerduty.com"
    }],
    "details": {
      "ping time": "1500ms",
      "load avg": 0.75
    }
};
triggerAlert(event, function(err, incident_key) {
  //your code here
});

The resolve() function requires either a string incident_key argument or an object with an incident_key field. See PagerDuty's documentation for other fields you might pass.

command-line tool

You can create an event using the handy command-line tool pd-trigger. Usage:

pd-trigger "One of t'flayrods has gone out of skew on treadle!"

It will respond with the ID of the incident created. You can then feed that ID to the resolve script: pd-resolve incident-id.

License

ISC.

Current Tags

  • 1.0.1                                ...           latest (4 years ago)

2 Versions

  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 3
This Month 3
Last Day 0
Last Week 1
Last Month 3
Dependencies (2)
Dev Dependencies (3)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |