IBM Bluemix Integration Guide

The IBM Bluemix cloud platform helps you solve real problems and drive business value with applications, infrastructure and services. Bluemix 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 Configuration menu and select Services.

  2. On the Services page:

    • If you are creating a new service for your integration, click Add New Service.

    • 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 the New Integration button.

  3. Select your app from the Integration Type menu and enter an Integration Name.

    If you are creating a new service for your integration, in General Settings, enter a Name for your new service. Then, in Incident Settings, specify the Escalation Policy, Notification Urgency, and Incident Behavior for your new service.

  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. Save the Integration Key for your new integration.

In IBM Bluemix

  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