I’ve been tasked to writing a python script to validate database restores and, if the restore fails, to trigger a PagerDuty incident. The main body of the script is finished, but I am having trouble with the part that would trigger an incident.
I’ve looked at pdpyras and I’ve looked at the example script at https://github.com/PagerDuty/API_Python_Examples/blob/master/REST_API_v2/Incidents/trigger_incident.py. The latter seems like it would meet my requirements better than pdpyras, but I have some questions about some of the variable values in the script.
“API_KEY” is self-explanatory, but are there specific values required for “SERVICE_ID” and “FROM”, or are those values that I can assign? I’m working in a GovCloud environment, so I want to be sure that the URL “https://api.pagerduty.com/incidents” is appropriate for what I’m trying to do. “api.pagerduty.com” is reachable from the server, from which the script will run:
$ nc -zv api.pagerduty.com 443 Connection to api.pagerduty.com 443 port [tcp/https] succeeded!
I would also like to know whether the “incident_key” is an arbitrary MD5 hash that I can generate. Lastly, I would like to know if the example script actually triggers an incident. It looks like it simply prints out a status code and the information collected in the “payload” JSON block. If that is the case, how do I actually send the incident to my PD Incident dashboard?