You can now extract fields from the email alerts and map them to Freshservice. You can subsequently create more powerful alert rules for your email integrations.
Let's take an example to help you get started.
Scenario: Assigning "resource" from the email body to the Freshservice alert field
Let’s assume that you are sending the following email alert to Freshservice.
For instance, you want to get the resource field from the email body and assign it to Freshservice alert resource field. Let's break this down step by step.
Case 1: Working with a new email monitoring tool integration
1. Enable the map alert field toggle.
2. Paste a sample email alert that your monitoring tool will generate. You can choose to input either the text version of the email body or the HTML code of the email body. The version you choose will determine the source on which the system will apply regex. For our example, we chose the text version. Click on "Save & Continue" to move to the next page.
3. On the alert field mapping screen, click on "Resource" from the list of available fields.
4. Select "email body (text)" as the email field.
5. Enter the following expression in the Regular expression field to extract the resource field from the given email body.
NOTE: Depending upon the expression entered, you will be able to see matchgroups under the values field. We allow upto 3 matchgroups.
In this example, the system will look for the keyword "Resource" and extract any values present after ":" and before the newline character (↲).
6. Choose matchgroup1 under the values dropdown to assign the matched value within the brackets of the regular expression.
In this example, it is as-w12-fat.
7. The system will apply the Regular Expression and the Match Group preference on the sample email and extract the first value that matches the expression. You will see the result under Content Preview.
8. Click on Save.
You have successfully extracted the Resource field from the email body and mapped it to the Resource field in Freshservice Alerts.
Similarly, to get Severity from the email subject.
1. Follow steps 1-8 and select Severity instead of Resource in Step 3.
2. Change the regular expression to Severity:\s*(.*) instead.
3. Additionally, modify the severity mapping to match the severity values you expect to be present in the email. In this example, you will add the keyword "High" mapped against the critical severity level. Therefore, whenever the email contains "Severity" as "High", the corresponding freshservice alert will have Critical Severity.
As a best practice try to create a regex for Severity that does not include leading or trailing spaces
4. Click on Save.
You can use regular expressions to extract any part of your email (e.g., Email subject) to map it to one of the freshservice alert fields.
To get the resource name from a subject like
Alert: CPU utilization is high on ec2-123-machine
Where the resource name is ec2-123-machine
You can use the expression
To get the node from an email body like
Device:eu-north [node: 22.214.171.124] Status:Not Responding Message:(Server not responding) Error code: 500
Where the node value is 126.96.36.199
You can use the expression
You can use any online tool available for free to validate your regular expressions and get more information about them. Some of them are listed below:
For more assistance, contact email@example.com