Auto Link Alerts to Jira Service Management Incidents

Summary

When working with JSM Incidents there is no way to automatically link Opsgenie Alerts to JSM Incidents. Or is there? 

With the new Incident REST API and the Opsgenie Alerts API, we can GET Alerts and also link alerts using two API requests. 

Automation Rule configuration:

  • Manual Automation Trigger

In this example, we will be using a Manually triggered rule to first get the Opsgenie Alerts where the Status is Open and there is a message of intermittent. This default value set on the Manually Triggered Automation Rule will look for Alerts that meet this criteria. Please note that this default value can be changed based on your use case and if you want to look at the message/status, or other values on the Alerts:

Default Value for User Inputs

status: open AND message: intermittent

Smart Value for Manually Triggered Rule

{{userInputs.alertsQuery}}

Screenshot 2023-07-13 at 8.10.56 AM.png

  • GET Request using a Send web request Action

Then we will be using a GET request to get the Alerts to later link using the following Web request URL. Please be sure that the smart value from the Manual Trigger is used for the query, and then url Encode the request URL, similar to below:

https://api.opsgenie.com/v2/alerts?query={{userInputs.alertsQuery.urlEncode}}

You will also need to get a Genie Key from an Opsgenie API integration to authorize the API request and get the Alerts:

Screenshot 2023-07-13 at 8.11.05 AM.png

  • POST Request using a Send web request Action

Lastly, we will link the alerts to the JSM Incident dynamically using the following POST web request URL. Please be sure to use your own cloud for your Jira site with experimental API headers, using Basic Authorization:

https://api.atlassian.com/jsm/incidents/cloudId/<cloud_id>/v1/incident/{{id}}/alert/add
X-ExperimentalApi opt-in
Authorization Basic <api_key>

Also, here is the custom JSON data you want to pull in the web response data from the previous API GET request:

{
"alertIds": {{webResponse.body.values.id.asJsonStringArray}}
}

Screenshot 2023-07-13 at 8.48.15 AM.png

Once this is all setup and you manually trigger the rule you will see linked alerts that met the criteria for the rule linked now, within the Linked Alerts field:

Screenshot 2023-07-13 at 8.44.06 AM.png

Related articles:

4 comments

Ken Young
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 13, 2023

One helpful thing when using this is to make sure you are using the IssueID vs the issue key (like most other api calls do) otherwise you will get a 404 error when trying to link to the alerts

Like Christian Beaulieu likes this
Christian Beaulieu
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 16, 2024

Great point Ken! Thank you :) 

Palak Setia
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 27, 2024

This is awesome @Christian Beaulieu

 

One thing to call out, for all new customers using JSM Premium and above, or existing customers who have recently moved to the new consolidated JSM + Ops Genie experience, this is no longer necessary. You can simply use Alert Automation to "Create Incident" and within that, there's an option to Include links to the Alert being referenced. 

Like Alan Skillings likes this
Devi Gattu August 5, 2024

Hi Team

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events