Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PubNub DevOps BLOCK w/ PagerDuty
export default (request) => {
const xhr = require('xhr');
const integrationKey = 'YOUR_INTEGRATION_KEY';
const apiUrl = 'https://events.pagerduty.com/generic/2010-04-15/create_event.json';
const description = request.message.description;
const httpOptions = {
method: 'POST',
body: JSON.stringify({
service_key: integrationKey,
event_type: 'trigger',
incident_key: "incident_" + parseInt(Math.random() * 10000),
description: description
})
};
return xhr.fetch(apiUrl, httpOptions)
.then((response) => {
console.log(response);
request.message.result = response;
return request.ok();
})
.catch((e) => {
console.error(e);
return request.ok();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment