@sanjmonkey wrote:
Hi PD community,
I’ve just picked up a project where I’d like one of my apps to trigger events and resolve alerts based on thresholds the app gets from looking at devices. However, I’m struggling to find how when hitting eventsv2 endpoint (https://events.pagerduty.com/v2/enqueue) the incident_key in the incident can be populated at time of creation? No matter where I put it in the parameters or payload, it always ends up as ‘None’ in the subsequent incident. All the alerts subsequently created under incident contain the dedup_key, but, I want to be able to uniquely identify the incident based on my apps dedup_key I specify, without having to recurse all incidents associated alerts…
Heres an example taken from the class I’ve written - can you tell me where I’m going wrong?
def trigger(self, description, hostname, details, dedup_key=None): data = json.dumps({ 'routing_key' : SERVICE_KEY, 'event_action': 'trigger', 'incident_key' : 'my-identifiable-incident-key', 'dedup_key' : dedup_key, 'payload' : { 'summary' : description, 'custom_details': details, 'source' : hostname, 'severity' : 'error', }, 'client' : '%s running on %s' % (sys.argv[0], os.uname()[1]), 'client_url' : 'https://my.super.awesome.app.net', }) r = requests.post('https://events.pagerduty.com/v2/enqueue', headers=self.headers, data=data, ) return r
When setting dedup_key in the above, it is the dedup_key in the associated alert. But incident_key is always None in the incident. If I chose to POST ‘incident_key’ in the ‘payload’, incident_key’ never ends up in the actual ‘incident_key’ field when pulling back the incidents again…
I’ll happily use another (appropriate) customisable field if it can make it into incident at time of creation, but I’m wondering why this is the way it is…?
Cheers!
Sandy
Posts: 3
Participants: 2