Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,366,308
Community Members
 
Community Events
168
Community Groups

Add Issue Key and URL to Incident

Edited

Dear all,

i am using opsgenie ,OEC and Python Script for creating some jira issues with some custom jira fields which are not filled by default,the synchronization opsgenie-jira works fine and the jira tickets are created.I use the following scenario:

  • I select e.g an alert and create manually for this alert an incident.
  • Incident itself creates an R alert and based on some rules which i defined,the R alert triggers the ticket creation.

But i would like also to have within Incident the Issue Key and URL under Extra Properties,like below:
Issue Key.JPG

Could you pls give me a hint how to achieve this?I use this py script

Regards
Oltion Alimerko

1 answer

0 votes
Samir Atlassian Team Jan 14, 2022

Hi @Oalimerko ,

 

You could have the script add those fields to the Incident via Incident API. The responder alert that is triggering your script will have the incident-id as an Extra Property

e.g.

2022-01-14_09-13-14.png

 

So you could have your script use that incident-id for the API request to update the incident fields with those additional fields.

 

Hope this helps!

 

Thanks,

Samir

Hi @Samir ,

i am not sure if i got it right.Do you mean first create incident manually and then update it via API or create the incident directly via API?

Samir Atlassian Team Jan 14, 2022

@Oalimerko It sounds like the responder alert created from the incident is triggering OEC to create the issue in Jira, right?

If so - that means the incident is being created before the Jira issue is being created.

So I was thinking modify the script that is creating the Jira issue, so that after it gets the response from Jira that the issue was created, it updates the incident with the additional fields via Incident API.

@Samir ,
now i got your idea.But how can the script gets the response from Jira that the issue was created,especially how to get the issue key?
In order to update the incident,first i need the incidentId of respective incident,how to get it?

Do you have any code example?

Samir Atlassian Team Jan 14, 2022

@Oalimerko 

I don't have an example of the script. But the script is receiving the details of the responder alert from Opsgenie, which is then used to create the issue in Jira. So you could make another Get Alert API request back to Opsgenie to get all the responder alert fields (the incident-id  field is an extraProperty of the responder alert as shown in my screenshot in my initial reply).

So you can grab that incident-id and assign it to a variable in the script.

Then when it makes the request to Jira to create the issue via API, it then grabs the response of that api request (line 256 below) and grabs the issueKey that is returned, and then adds that issueKey as an extra property to the alert.

2022-01-14_11-14-50.png

So you could add lines there for it to then make an Add Details to Incident API Request (since you have the incident-id), and add the Jira issueKey and link to jira issue as details (i.e. extra Properties) to the incident.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS

Atlassian Community Events