Created
November 21, 2014 21:58
-
-
Save ryanhoskin/6da5774bbc24dfe09068 to your computer and use it in GitHub Desktop.
Trigger a PagerDuty incident
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This script can trigger an incident in PagerDuty | |
#Hit the PagerDuty Integrations API, echo results | |
function POST_Request ($url,$parameters) { | |
$http_request = New-Object -ComObject Msxml2.XMLHTTP | |
$http_request.open('POST', $url, $false) | |
$http_request.setRequestHeader("Content-type", "application/json") | |
$http_request.setRequestHeader("Content-length", $parameters.length) | |
$http_request.setRequestHeader("Connection", "close") | |
$http_request.send($parameters) | |
Write-Host "Server Response:" $http_request.statusText | |
} | |
#Parameters | |
$service_key = "538e4904f2474722933ee2f4b1051a53" | |
$description = "heartbeat" | |
$incident_key = "heartbeat" | |
$url = "https://events.pagerduty.com/generic/2010-04-15/create_event.json" | |
$parameters = New-Object Collections.Specialized.NameValueCollection; | |
#Trigger an incident | |
Write-Host "Triggering incident" | |
$event_type = "trigger" | |
$parameters = "{`"service_key`":`"" + $service_key + "`",`"event_type`":`"" + $event_type + "`",`"description`":`"" + $description + "`",`"incident_key`":`"" + $incident_key + "`"}" | |
POST_Request $url $parameters |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment