You can set the alerts responders field in OpsGenie based on an Insight custom field in Jira. Following the below steps you’ll be able to achieve that.
Insight Custom Field
Create a custom field in Jira with type Insight objects. This object needs to have an attribute to store the Team ID from Opsgenie:
You can get the Team ID in Opsgenie by clicking on the relevant team on the Teams page and checking the ID on the URL:
Add this ID value to the attribute on the Insight custom field:
Add this custom field to the relevant project/screens.
Jira automation rule
Create an automation rule in Jira as specified below:
Trigger: choose the option Incoming webhook. Automation for Jira will create a Webhook URL, similar to the one below:
Copy the URL generated to be used in Opsgenie
Opsgenie integration
In Opsgenie create a new Webhook integration similar to the one below, using the URL generated by Jira automation:
Back to the Jira automation rule
Action: create a Lookup issues action using the response from the Webhook:
key = {{webhookData.alert.alias}}
Action: create another action Send web request to the Opsgenie Add Responder to Alert API:
URL: https://api.opsgenie.com/v2/alerts/{{webhookData.alert.alias}}/responders?identifierType=alias
Custom data:
{
"responder": {
"type":"team",
"id":"{{lookupIssues.first.INSIGHT CUSTOM FIELD NAME.ATTRIBUTE NAME}}"
}
}
It’s necessary to change the name of the Insight custom field and the attribute on the ”id” field.
This way, every time an alert is created based on a JSM ticket which has the Insight custom field, the responders will be set via API according to the value defined on the attribute.
André Sinatora
0 comments