Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

message.extract, regex and line breaks (oh my!)

Allen Wolf
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 21, 2023

Thanks to the support docs and other questions here, I've made great progress in using message.extract to populate tags and extra properties fields. But I have one situation where I'm failing to extract data, my property is always blank. I'm guessing it has to do with line breaks, since my other extracts were always from a single line. I've looked at the alert from the web UI, and also exported via API, and I have regex that will match either format, but it's still not matching.

My extract string:

{{ message.extract(/SEARCH STRING(?:\\r\\n +)*\n*(\S+[^\\\n]+)/) }}
(the string I'm extracting will vary a lot, so I can't just find word "vendor", but the string "SEARCH STRING" is constant, which is my I'm trying to use that as the 'anchor' for my regex)
Description when viewed from web UI:

Screenshot 2023-04-21 at 10.38.29 AM.png

Description when pulled via API:

Screenshot 2023-04-21 at 10.41.20 AM.png

Test of regex string:

Screenshot 2023-04-21 at 10.45.17 AM.png

 

Thanks in advance for any tips!

1 answer

0 votes
Talar Pavlovic
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 24, 2023

Hey there Allen,

Thanks for writing into Opsgenie Community, I'm Talar from the Atlassian team, happy to help.

In this instance, it would be worth trying the .removeAllWhitespace() command to see if that will help return the string required. 

Regards,
Talar  

Allen Wolf
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 26, 2023

Thanks!! This would go before the extract I assume? so {{ message.removeAllWhitespace().extract(/<regex>/) }}

 

EDIT: this might get me closer, but some of the strings I'm trying to capture will have spaces. Is there a way to see the Description / Message field, formatted in the same way as the regex engine 'sees' it? 

EDIT: either way, my regex still isn't working

{{ message.removeAllWhitespace().extract(/SEARCHSTRING(.*)RULEREASON/) }}

 

Thanks!

Talar Pavlovic
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 27, 2023

Sure - you can see how the payload in the Opsgenie Logs. To do this: 

  1. Open the Alert and go to the Activity Log tab
  2. Scroll to the very first entry at the bottom and copy the "IncomingDataId". 
  3. Go to Settings > Logs 
  4. Search for "<incomingdataid>" making sure the timeframe is wide enough to capture this alert 

If you do need more specific assistance here could I recommend putting in a support ticket so we can look at your payload and advise accordingly? 

Regards,
Talar 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events