IBM Cloud Integration Guide

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.

In PagerDuty

  1. Go to the Services menu and select Service Directory.
  2. On the Service Directory page:
    • If you are creating a new service for your integration, click +New Service and follow the steps outlined, selecting this integration in step 4.
    • If you are adding your integration to an existing service, click the name of the service you want to add the integration to. Then click the Integrations tab and click Add a new integration.
  3. Under Select the integration(s) you use to send alerts to this service search and select this integration.
  4. Click the Add Service or Add Integration button to save your new integration. You will be redirected to the Integrations page for your service.
  5. Find the integration in the list, click the v dropdown on the right and copy the Integration Key. Keep this key in a safe place for later use.

In IBM Cloud

  1. Copy the following JavaScript code.
    // 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);
    			}
    		});
    	});
    }
  2. Open your OpenWhisk Editor.
  3. Click on Create an Action.
  4. Paste the code you copied above into the editor.
  5. Click on Make It Live.

FAQ

What parameters can I pass to my action?

The OpenWhisk action can ingest any parameter that is accepted by our Events API v1.

How can I trigger an incident using this action?

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

How can I manage an incident using this action?

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

Start Using PagerDuty Today

Try PagerDuty free for 14 days — no credit card required.

SIGN UP