Update Opsgenie alert priority when the issue priority in Jira is changed

 

Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.

The solutions suggested in this article are only applicable to sites using Jira Service Management bundled with Opsgenie. They don't apply to sites migrated to the new streamlined incident management experience.

Purpose

With the new Jira Service Management / Jira Opsgenie integration, the priority of the alert matches the issue priority only at the time of creation. The alert priority in Opsgenie is not updated when the issue priority in Jira is changed.

This is expected behavior as it is not part of the integration. We're tracking the feature request here:

Environment

Jira Service Management Cloud / Jira Cloud integrated with Opsgenie via the New Integration:

Solution

You can update the Alert priority with an Automation Rule on Jira. You can follow one of the below approaches to configure the Automation rule:

Method 1: Manually configure the Automation Rule by the steps provided or the Video
  1. Create an API Key in Opsgenie for Authorization purposes.
    1. Login to Opsgenie and navigate to Settings → API key management.
    2. Click on Add new API key which will display a pop-up. Add a Name > select the following option for Access rights:
      -
      Read
      - Create and update.
    3. Make a note of the API key displayed under the field Key, this will be the API key used for the Authorization later in the Automation rule, and then click on Add API key.
  2. Create an Automation Rule in Jira.
    1. Open the project that you have chosen while adding the Jira Service Management/Jira integration in Opsgenie.
    2. Navigate to Project Settings → Automation → Create Rule.
      1. Trigger: Select the Field Value Changed action and select the Priority field, select Any Changes to the field value for the Change Type field, leave the For field blank (i.e. All Issue operations), and then click Save.
      2. New Condition: Select the If/Else Block.
    3. Here we set the condition and check the value of the priority field. Click on + Add conditions.. → Issue Fields condition
      1. Select Priority under Field
      2. Equals for Condition
      3. Value select Highest (you can modify this value accordingly) and then click Save.
    4. On the next screen choose New Action and search for Send web Request action and click on it.
    5. Paste the below values accordingly:

      Web Request URL:  https://api.opsgenie.com/v2/alerts/{{issue.key}}/priority?identifierType=alias
      Headers:
                        Authorization:
      GenieKey <API Key from Step 1.c above>
                        Content-Type:
      application/json
      HTTP method:
      PUT
      Web request body:
      Custom data
      Custom data: 

      {
          "priority":"P1"
      }
    6. Click Save.
    7. Click on Add Else and continue the steps from 2c through 2f and add conditions to check all the priority and send the Web Request accordingly.


Link to the Video: Update Opsgenie Priority.mp4

Here is the Priority mapping between Jira and Opsgenie. You can always modify according to your needs:

JiraOpsgenie
HighestP1
HighP2
MediumP3
LowP4
LowestP5
Method 2: Import the Rule to your site
  1. Create an API Key in Opsgenie for Authorization purposes.
    1. Login to Opsgenie and navigate to Settings → API key management.
    2. Click on Add new API key this will display a pop-up, add a Name and select the following option for Access rights : " Read" and " Create and update".
    3. Make a note of the API key displayed under the field "Key", this will be the API key used for the Authorization later in the Automation rule, and then click on Add API key.
  2. Import the Rule to your Cloud instance
    1. Download the following file: Update Opsgenie Alert Automation rule.json
    2. Navigate to → System → Global Automation.
    3. Click on the 3 dots () in the top right corner and select the Import rules option.
    4. Click on the Upload JSON button, this will open your system File Explorer, select the file that you downloaded in Step 2a.
    5. Click on the Check Box to select the rule you want to import and select the project where you would like to import this rule. Please do not click on the Import rule owner checkbox and click Next.
    6. Click Let's do this on the next screen, and this will successfully import the rule to the project.
  3. Update the API key on the Authorization header.
    1. Open the rule that was imported.
      1. Project Settings → Automation → Find Opsgenie Alert Update rule
    2. You will see 5 Send web request actions configured in this rule, open each of these actions and replace the "GenieKey xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" to "GenieKey <The API Key you created in Step 1.c> " under the Authorization Header.
    3. Feel free to edit the Priority values as per your needs. 
    4. Click on the Save button on each of these actions after the modification.

The rule is now completely configured.

Last modified on Jan 31, 2025

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.