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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,551,932
Community Members
 
Community Events
184
Community Groups

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!
Apr 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.
Apr 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!
Apr 26, 2023 • edited Apr 27, 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.
Apr 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