https://support.atlassian.com/opsgenie/docs/dynamic-fields-in-opsgenie-integrations/
...
Table of Contents | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
Overview
Jira Service Management parses your data to construct rich and informative alerts. You can use dynamic fields properties to customize alert properties, as well as alert your alerts and alert conditions.
...
Dynamic (draggable) properties
Draggable fields properties bring significant data for creating and managing well-informed alerts. Opsgenie Integrations Framework The integration framework provides different dynamic fields for every integration, properties specific to the integrated toolapplication. Dynamic fields can be used in Filters You can use dynamic properties in the filters of your integration actions as well as Alert Fieldsalert fields. In Filterthe filter, fields dynamic properties are available to choose select in the condition drop lists-down. In Alert Fieldsthe alert properties, you can just drag a dynamic field property into any input alert field you find appropriate.
View file | ||
---|---|---|
|
The expressions with Jira Service Management interprets the expressions within the double-curly braces are interpreted by Opsgenie as dynamic fields; and populated with dynamic data properties. Dynamic data populates at every notification that's sent to OpsgenieJira Service Management. For example, let's say someone created creates an issue in JIRA; Jira and entered enters "This is the summary" as for the summary. Using Opsgenie's JIRA Jira Service Management’s Jira integration, "[Jira] {{summary}}" for Message in a 'Create Alert alert' Action will yield creates an alert with the message "[Jira] This is the summary" and . It will then notify the users. All we needed to do was is drag {{summary}} to Message; and when the message. When the issue was created Opsgenie automatically got notified and created is created, Jira Service Management gets notified automatically. It creates an alert with the issue's summary in the message for us.
You can mix static text with dynamic fields. As you can see in properties. In the example above, the "[Jira] " in "[Jira] {{summary}}" is static and will it'll be at the beginning of the message for every created new alert's message. "{{summary}}" can be different for each alert.
Using
...
raw parameters from webhook URL, payload, and headers
You can also inject url insert URL parameters or http payload parameters from webhooks directly into your alerts. Let's clarify with an example:Suppose you're using Opsgenie Jira integration. Jira sends to Opsgenie For example, an integrated application sends a variable named timestamp to Jira Service Management in the webhook payload; but . But timestamp hasnisn't been made available as a draggable field in the Integrations pageproperty in the configuration page. If you still need to use timestamp in your alerts, you can :
...
Go to Advanced Settings of your integration
...
add {{_payload.timestamp}}
to
...
the input
...
field.
...
Save the integration.
Nested payload variables are accessible as well. In the Jira example, we could also use use _payload.issue.fields.environment to environment to access the following value that is in the http body of the webhook:Text
Code Block |
---|
{
"issue" : {
"fields" : {
"environment" : "env_val"
}
}
}
|
Url The URL query parameters of a webhook are also accessible via {{_url.param}}
where param is the parameter key. You can add custom parameters to the webhook url URL and inject it into your alerts. To clarify this with an example:
Suppose For example, suppose you're using Opsgenie Jira Service Management’s Stackdriver integration. You're monitoring multiple many projects and want to use a single integration for all your alerts, but . If you still want to have a way of distinguishing distinguish which alert belongs to which domain. One thing , you can do is to use a custom parameter for each of your projectprojects.
You can add your custom parameter to the webhook url URL of the Stackdriver integration, like . For example: ¶m1=val1, and insert {{_url.param1}}
in the integration config to access it.
Note |
---|
Note that accessing request url, payload and headers parameters is not available for actions via Alert API |
Headers of a webhook request is are also available via {{_headers.param}}
where param is the name of the header. You can use all the headers of a request in your alert fields.
Info |
---|
You For email-based integrations, you can use headers of an email via {{_headers.PARAM1}} notation for the email based integrations. For example, you can use and {{_headers.IMPORTANCE}} in the alert fields for an email based integration. Note that you should use . Use UPPER CASE letters for the keys. |
You can also To control your alert fields further, you can use string processing methods on dynamic fields to further manipulate and control your alert fieldsproperties. For example, your Opsgenie JIRA an Integration has an 'Add Note Action' action, and Note is configured as "note: {{comment_body.substringAfter("is")}}".
Now when someone in JIRA comments on an issue with the integrated application adds "This is the comment" , the Opsgenie alert that's associated with the issue will be added a noteas a comment to the issue, a note is added to the corresponding alert, with the text "note: the comment".
The complete list of methods you can use in dynamic fields are listed below:
substring(int from), substring(int from, int to): yields the string between specified indices. from is included to is excluded
{{ from_name.substring(5,20) }}
substringAfter(String from): yields the string between specified indices. from is included to is excluded
{{ subject.substringAfter("Host") }}
substringBefore(String to): yields the string before the specified parameter
{{ from_address.substringBefore("@") }}
substringBetween(String from, String to): yields the string between from and to parameters
{{ subject.substringBetween("URL:","(") }}
extract(regular expression): yields part of the string that matches the parenthesized section of the regular expression.
{{ message.extract(/Host: (\S+)/) }}
toDate(String format) converts millisecond-based timestamp into date format, following Java formatting . The default format is "yyyy-MM-dd HH:mm:ss ZZZ".
{{create_timestamp.toDate()}}
get(int index) yields the element at the given index of an array.{{myArray.get(0)}}
Read more about string processing methods.