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?
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
Can you give us an example?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.