Start Using PagerDuty Today
Try PagerDuty free for 14 days — no credit card required.
The IBM Cloud platform helps you solve real problems and drive business value with applications, infrastructure and services. IBM Cloud makes it possible to bring together multiple data sources, scale systems, and incorporate cognitive services to drive business value quickly and inexpensively.
// This action will trigger or resolve an incident within PagerDuty // // The params object passed to the action should be a payload formatted for the PagerDuty Events API // The params object must contain a "service_key" and "description". The "event_type" will default to "trigger". // // https://v2.developer.pagerduty.com/docs/trigger-events var request = require('request'); function main(params) { // Check for required params if (!params.service_key || !params.description) { throw 'params must include service_key and description'; } if (!params.event_type) { params.event_type = 'trigger'; } console.log(`Params: ${JSON.stringify(params)}`); // Set request options var options = { url: 'https://events.pagerduty.com/generic/2010-04-15/create_event.json', method: 'POST', json: true, body: params }; // Make POST request return new Promise(function(resolve, reject) { request(options, function(error, response, body) { if (error) { reject(error); } else { resolve(body); } }); }); }
The OpenWhisk action can ingest any parameter that is accepted by our Events API v1.
You can trigger an incident in PagerDuty by invoking your OpenWhisk action with parameters set to trigger an incident on our Events API v1. For example, the command below uses the OpenWhisk CLI to trigger an incident where the integration_key is bdb63026b4514cd7b143604f460cca30f; this command assumes that your action is named pagerduty.
wsk action invoke pagerduty --blocking --result --param event_type trigger --param description "Server is on fire" --param service_key bdb63026b4514cd7b143604f460cca30f
You can manage your incidents by invoking the PagerDuty action with the incident_key for the incident you want to manage and the event_type for the incident’s updated state. Below are two examples that will acknowledge and resolve the incident, respectively.
wsk action invoke pagerduty --blocking --result --param event_type acknowledge --param service_key bdb63026b4514cd7b143604f460cca30f --param incident_key 8e6cd11a23a34985b4a94fd556326132
wsk action invoke pagerduty --blocking --result --param event_type resolve --param service_key bdb63026b4514cd7b143604f460cca30f --param incident_key 8e6cd11a23a34985b4a94fd556326132
Try PagerDuty free for 14 days — no credit card required.