Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Improvement of the Opsgenie notification title

Temgoua Nguefack Christian Midrel February 27, 2025

Hello, We are trying to improve the title of the Opsgenie notifications.

We have a payload that is sent to Opsgenie, and we would like to include a field from this payload in the notification title. {{_payload.ProblemDetails.impactedEntities.get(0).entityId.type}}

However, we are finding it impossible to retrieve the (type) element in question. We followed this documentation: https://support.atlassian.com/opsgenie/docs/dynamic-fields-in-opsgenie-integrations/

We tried using regex expressions to extract this field from the payload, but the result was an empty field. We are also wondering if there is a limit on the number of characters in the title.

We noticed that when we used {_payload.ProblemDetails.impactedEntities.get(0).entityId.type}}, we received an error in Opsgenie, but when we used {_payload.ProblemDetails.impactedEntities.get(0)}, we got a result, although it was not usable in the title.

Can you tell us if it is possible to extract fields from a JSON object within the payload?

1 answer

1 vote
Robert
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 28, 2025

Hey @Temgoua Nguefack Christian Midrel !

At this time, using get() will "stop" the ability to descend further into the object. That is, once you use the get() method you'll have to use some type of string processing method to continue extracting data, treating the result of the get() as a string.

So in your example, something like

{{_payload.ProblemDetails.impactedEntities.get(0).extract(/someRegexHere/)}}

Should be able to extract something more specific after getting the first element of the array. 

Hi @Robert,
Thank you for the feedback. We are receiving a payload from Dynatrace and we would like to extract the "name" field. We have tried this extraction but we are getting an empty result.
{{_payload.problemDetailsJSON.impactedEntities.get(0).extract(/ "name"\s*:\s*"([^"]+)/)}}

Below is the payload

{
  "State": "OPEN",
  "ProblemID": "P-34335",
  "ProblemURL": "https:\/\/some.url.com\/#problems\/problemdetails;pid=-34ccece49164V2",
  "ProblemTitle": "Title",
  "ProblemImpact": "APPLICATION",
  "problemDetailsJSON": {
    "problemId": "34ccece49164V2",
    "displayId": "ddwwfe",
    "title": "Title",
    "impactLevel": "APPLICATION",
    "severityLevel": "AVAILABILITY",
    "status": "OPEN",
    "impactedEntities": [
      {
        "entityId": {
          "id": "TEST-qdwwccw",
          "type": "TEST"
        },
        "name": "Entity1"
      }
    ]
  }
  }


Can you give us an example?

 

Robert
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 5, 2025

Hi @Temgoua Nguefack Christian Midrel 

One thing that sticks out is that you may need to escape the quotation marks. I also simplified the expression a bit and something like 

/\"name\": \"(\S+)\"/

May work for this. Ultimately if it is blank then that means the regex isn't matching. So it is best to make the expression more generic until you do get a result, then make it more specific to narrow down the issue. 

@Robert
I have the same blank result. 

Could you provide me with an other  expression or something that I could even use at the level of impactedEntities from the payload above?

Robert
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 5, 2025

Hi @Temgoua Nguefack Christian Midrel 

substringBetween may be a simpler option for this case: 

x.substringBetween("\"name\": \"","\"")

Or something along those lines should be able to extract the value for the "name" key. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
ENTERPRISE
TAGS
AUG Leaders

Atlassian Community Events