Alerting

Is there a way to change the font size or bold text in alert emails?

kiran331
Builder

Hi

Is there a way to change font size or Bold text in email alerts? Can this be done by scripting?

Tags (4)
0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

Out of the box Splunk's email system escapes all HTML elements, so if you used <b>this is bold</b> it would appear literally.

You can change that behaviour quick and dirty by making a backup of etc/apps/search/bin/sendemail.py, modifying the original by changing ${msg|h} to ${msg} in line 672, and then using HTML in your alert email texts.
HOWEVER, you have to be aware of a few things:

  • This won't survive an upgrade, you'll have to reapply the change every time
  • This change is global to your Splunk instance, affecting every single email sent
  • Unexpected things may happen if existing emails already contain HTML-like things
  • Bad things may happen if your users craft email alerts to mess with recipients' inboxes

A nicer way would be to write a custom alert action as a kind of "advanced sendemail" without the escaping of HTML elements, and only grant permission to this to advanced users. That wouldn't be global, would survive upgrades, would be shareable on splunkbase, but would be a bit more effort.

View solution in original post

martin_mueller
SplunkTrust
SplunkTrust

Out of the box Splunk's email system escapes all HTML elements, so if you used <b>this is bold</b> it would appear literally.

You can change that behaviour quick and dirty by making a backup of etc/apps/search/bin/sendemail.py, modifying the original by changing ${msg|h} to ${msg} in line 672, and then using HTML in your alert email texts.
HOWEVER, you have to be aware of a few things:

  • This won't survive an upgrade, you'll have to reapply the change every time
  • This change is global to your Splunk instance, affecting every single email sent
  • Unexpected things may happen if existing emails already contain HTML-like things
  • Bad things may happen if your users craft email alerts to mess with recipients' inboxes

A nicer way would be to write a custom alert action as a kind of "advanced sendemail" without the escaping of HTML elements, and only grant permission to this to advanced users. That wouldn't be global, would survive upgrades, would be shareable on splunkbase, but would be a bit more effort.

linu1988
Champion

Adding to Martin's point, you may as well create a scripted solution which will give you more flexibility.

Moreover if you are just copying the sendemail.py to your own app it will not be overwritten upon upgrade but may malfunction upon the original sendemail.py structure change for on splunk instance. I have been following the same method for colors, font, resizing text + own scripted alerts.

0 Karma

kiran331
Builder

Hi Linu1988, Thanks for the response!Can you share the script for resizing text.

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

If you have a solution built, do consider sharing that on splunkbase 🙂

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...