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.


Sample email:


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.


1. Go to the map alert fields section. and click on add a new mapping


2. For our example, select "email body (text)" as the email source.


3. Enter the following expression in the matched expression field to extract the resource field from the given email body.

Resource:\s*(.*)


NOTE: The matched expression field accepts any valid Regular Expression as input. 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 (↲).


4. 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.


5. Finally, select Resource from the alert fields dropdown.

6. 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-4 and change the regular expression to Severity:\s*(.*) instead.

2. Select Severity from the alert field's drop-down


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. 

For instance, 

  • To get the resource name for 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

[\S]{3}-[\S]{3}-[\S]{7}

  • To get the node from an email body like
    Device:eu-north [node: 179.42.241.136] Status:Not Responding Message:(Server not responding) Error code: 500

Where the node value is 179.42.241.136

You can use the expression 

[\d]{1,}\.[\d]{1,}\.[\d]{1,}\.[\d]{1,}

 

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:



Currently, the following Freshservice fields are available for mapping:
1. Message
2. Severity
3. Node
4. Metric Name
5. Metric Value

Watch out our release notes for more updates on this.




For more assistance, contact support@freshservice.com