Skip to content

Instantly share code, notes, and snippets.

@weldpua2008
Last active August 10, 2018 05:49
Show Gist options
  • Save weldpua2008/cee45cbbcc5e99adb96040c946464601 to your computer and use it in GitHub Desktop.
Save weldpua2008/cee45cbbcc5e99adb96040c946464601 to your computer and use it in GitHub Desktop.
Resolve PagerDuty Triggered Alerts

Resolve triggered alerts

need to setup token with export token= --header 'From: weldpua2008@com'

while [[ $(echo ${j}|jq ."incidents") != "[]" ]];do
j=$(  echo -n '{"incidents":'; curl -X GET --header 'Accept: application/vnd.pagerduty+json;version=2' --header "Authorization: Token token=${token}" 'https://api.pagerduty.com/incidents?statuses%5B%5D=triggered&time_zone=UTC&sort_by=created_at' |  jq -c  '.incidents|.[]|{ id: ."id", "type": "incident_reference", "status": "resolved"} '|  jq --slurp '.';echo -n '}' )
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/vnd.pagerduty+json;version=2' --header 'From: weldpua2008@com' --header "Authorization: Token token=${token}" -d "$j" "https://api.pagerduty.com/incidents"
sleep 1
done

Resolve single alert

Example Json

{"incidents":[
    {
      "id": "PEE92YQ",
      "type": "incident_reference",
      "status": "resolved"
    }
]}
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/vnd.pagerduty+json;version=2' --header 'From: weldpua2008@com' --header "Authorization: Token token=${token}" -d '{"incidents":[
    {
      "id": "PEE92YQ",
      "type": "incident_reference",
      "status": "resolved"
    }
]}' "https://api.pagerduty.com/incidents"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment