Skip to content

Instantly share code, notes, and snippets.

@dshack
Last active August 29, 2015 14:01
Show Gist options
  • Save dshack/2446ffdf9eb5a17f6c21 to your computer and use it in GitHub Desktop.
Save dshack/2446ffdf9eb5a17f6c21 to your computer and use it in GitHub Desktop.
PagerDuty webhook to dashing alert
--[[ PagerDuty sends a specific webhook format, and we need to translate it into an API call to Dashing.
You can paste this lua script into http://webscript.io to do the translation easily. You might be able to use Zapier to
do the same thing.
]]--
-- Get the incident ID, user, and trigger type from the PagerDuty webhook
local incidentid = json.parse(request.body).messages[1].data.incident.id
local user = json.parse(request.body).messages[1].data.incident.assigned_to_user.name
local desc = json.parse(request.body).messages[1].data.incident.trigger_summary_data.description
local trigger_type = json.parse(request.body).messages[1].type
log(request.body)
log(trigger_type)
if trigger_type == "incident.trigger" then
-- Post a number to the app
http.request {
method='POST',
url='http://mydashboard.herokuapp.com/widgets/incident_desc',
headers={
['Content-Type']='application/json'
},
data=json.stringify {
auth_token='YOUR_AUTH_TOKEN',
text = 'Incident '..incidentid..' assigned to '..user..': '..desc..'!'
}
}
else
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment