Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to close Opsgenie alerts when a Jira Cloud issue is moved to another project

This article explains how to close Opsgenie alerts when the related Jira issue is moved to another project using Jira automation rules.

These automations work by triggering a POST request to the Opsgenie /close API endpoint when an issue is moved to a new project. 

This is broken out into two rules:

  • One automation for alerts created from Jira issues
  • One for alerts from other integrations.

These both need to be global automations (Settings > System > Global automation)

For alerts that were created by Jira

The summary of the automation rule looks like this:

image-20230330-204438.png

The automation triggers when any issue is moved from the project where alerts are being sent. We also need a filter for the ‘fromOG’ label NOT being present because these issues were not created from Opsgenie alerts.

Our second automation rule (below) will cover the issues that WERE created from opsgenie alerts. 

On the web request, we’ll use this URL

https://api.opsgenie.com/v2/alerts/{{changelog.key.fromString.urlEncode}}/close?identifierType=alias

The smart value in the URL, {{changelog.key.fromString.urlEncode}}, will pull the original issue key and encode it for a URL.

In the headers, you’ll need to add an Authorization header from an API integration. The body will be custom data and just ‘{}’ in the field.

2024-01-10_13-42-06.png

For alerts that were created by other integrations

Since alerts from other integrations won’t have the issue key as an alias, we need to add a step to first get that data from the alert.

The summary of the automation rule looks like this:

image-20230330-205208.png

Time we’re filtering for the labels WITH ‘fromOG’, since these issues were created by Opsgenie.

The first web request is a GET to the alert API that lists alerts where the issue key is in the alert's details. Here is the URL:

https://api.opsgenie.com/v2/alerts?query=details.value%3A{{changelog.key.fromString.urlEncode}}

Now we can use the response from the previous step as an encoded smart value, which we'll send to the '/close' endpoint:

https://api.opsgenie.com/v2/alerts/{{webResponse.body.data.id}}/close

Now, all Opsgenie alerts linked to a Jira issue will be closed when any Jira issue is moved to a new project.

 

In order to ensure that we continue to provide useful content, please let us know if this Article is helpful (Thumbs Up/Down). Also, to help us improve, feel free to provide additional feedback (directly in the community).

1 comment

Karoline Rezende Ramos May 13, 2024

Hi @John M 

I'm trying to create and close the alert in opsgenie through Jira Automation, but I'm not able to close the alert. 😢

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events