HTML in description field of OpsGenie alerts

Michał Kłokowski April 1, 2022

Hi,

I have an issue with the "Description" field of the OpsGenie Alert coming from an Email integration. The email I receive looks like this in HTML:

Screenshot 2022-04-01 at 14.37.45.png

But the description of my generated alert is in one line with no proper spaces and line breaks. Is there anything I can do to fix this?

Screenshot 2022-04-01 at 13.14.54.png

I know that there is the html version in attachments, but I would like to add some extra properties and tags based on the content of the mail. The fact that it comes all in one line is causing some troubles with that and thus my question. Also what is strange, this was working properly some months ago and then all of sudden the alerts started to arrive as oneliners without a change to the email format. What could be the reason for that? 

3 answers

1 accepted

0 votes
Answer accepted
Tom Russell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 1, 2022

@Michał Kłokowski we deal with similar inbound emails from some of our monitoring systems. We usually don't just pass the message through to the Description field, but use multiple 'message.extract' statements, with regexes, to parse out the relevant information. (Loads and loads of message.extract, sometimes, unfortunately). This should work whether the message comes in as a single line or multiple lines, though finding field-end boundaries might be more difficult with a single-line message.

Michał Kłokowski April 5, 2022

Thank you for the reply. We implemented a similar solution now by using the extract method and adding some self defined delimiters into the mails' content.

Like # people like this
Koponkin July 3, 2023

@Michał Kłokowski Could you please share an example of your regex. I have the same problem but can't choose the right regex to extract my data. Not sure about the structure of {{ message }} if it's pure HTML or a string with some lines.

Michał Kłokowski July 3, 2023

Hi @Koponkin ,

In our case, we put custom tags in our alert bodies like this:


MY_TAG_APP: app-name
MY_TAG_ENV: preprod
MY_TAG_MESSAGE: this is a message
MY_TAG_END


 

Then in the OpsGenie integration, we use the following regex to extract the information and add them to the correct fields:


{{message.extract(/(?s)(?<=MY_TAG_APP:).+?(?=MY_TAG)/)}}


So basically we extract what is between "MY_TAG_APP" and "MY_TAG" (start of next tag) 

Hope this helps!

Mikel Stous February 5, 2024

Now that we have an Argent integration, we have less trouble with this.

We mainly have text incoming on emails, but pull variables out for automation.

{{ message.extract( /.*MY_TAG_APP: (.*).*/ ) }}

{{ message.extract( /.*MY_TAG_ENV: (.*).*/ ) }}

{{ message.extract( /.*MY_TAG_MESSAGE: (.*).*/ ) }}

0 votes
Dennis Sheen August 11, 2023

Just a note for others.  if you just want the whole body of the message (i.e. you don't want to parse out everything) and effectively just need line return chars to render properly you can just surround most text with pre tags.

e.g. 

<pre>
line 1
line 2
line 3
</pre>
will likely render good enough for most purposes.

0 votes
Alexandr Kalika August 8, 2022

we need to see user<->freshdesk <->opsgenie interaction and all messages are broken because they are wrapped by html in slack and they a looks terrible!!!!

 

TRY TO FIND TEXT within all that HTML GARBAGE around, could you only imagine.....

I found one more complaint https://jira.atlassian.com/browse/OPSGENIE-227 and ETA??? it is so ANNOYING as CAPS and more

please help Team, we count on your understanding!

much appreciated

 

ps

I've found a task  on this matter& hope you will include it into the upcoming "spring" https://jira.atlassian.com/browse/OPSGENIE-227

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events