Help with regex in Event rule from Description which is an email subject & body

Dhana1
Tera Contributor

Hi,

 

Can you help me with regex with the below email body which we are populating in Event Description field.

 

Need to get the Product Name and Affected Entity details for CI Binding so we require the regex to pick from [Product Name] to before [Please refer to the attachment for more details].

 

 

Event Description:

 

[Alert: Action Required] HQC_HANA Databases

*External]*



*Customer Communication*

[Alert: Action Required] HQC_HANA Database Space

[image: Customer Communication]

Dear Customer,

*Customer Name:* NorthgateArinso Belgium BV

*CSS Incident: *31169 2024

Below alert was identified for the impacted system, as part of proactive
monitoring.

We analyzed the system and we need the following information/action from
you  to resolve this alert.



Alert Name: HANA Database Space



Analysis/Action Required:



This is regarding HQCNG0 system, we received an alert for HANA Data Volume
Usage.

As of now OS space utilization has reached up to 92% for HANA Data mount
point.



From database, we have looked for housekeeping and we couldn't find any old
database backups. Also, data volume reclaim is not possible.

Request customer to evaluate the options for archiving/deletions data based
on business requirements from EWA report. If that option not viable, then
request for additional storage.

Kindly find the below given details and provide approval to increase the
mount point by (AWS 500GB, NON-AWS 200GB) minimum to avoid a
database(default) full situation which can cause system outage.



Impact: There may be an impact on system performance / availability if
there is no action taken.



Please refer to the Incident mentioned in the Email for more details
regarding this alert and our recommendations to resolve the issue.



If there are any further details required about this alert/recommendation,
then please revert to us, or contact your SAP Enterprise Cloud Services
Representative.



*Product Name*

*Affected Entity*

SAP Enterprise Cloud Services

*System Number:*
500403881
*System ID:*
HQC
*System Role:*
Test System

SAP Enterprise Cloud Services

*System Number:*
500403881
*System ID:*
HQC
*System Role:*
Test System

Please refer to the attachment for more details.

*Questions?*

Please contact SAP Support using the Support Hotline
.

1 ACCEPTED SOLUTION

Hi @Dhana1,

 

No worries. Let's see if we can help. Just to confirm you saw my update to the post where you can further test this regex and extract it and assign it to a variable as shown via a 'Background script' - please confirm

 

Is there a particular event rule you're running this against or can you give the use case so I can try and replicate?

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, Robbie

View solution in original post

4 REPLIES 4

Robbie
Kilo Patron
Kilo Patron

Hi @Dhana1,

 

Use the following regex:

 

/(?=Product Name)(.*?)(?=Please refer to the attachment for more details)/g;

 

(Checked and verified via regextester.com)

You can also test this as a background script (Type 'Scripts - Background' into the Navigation menu) and test using the following script:

 

var string = "[Alert: Action Required] HQC_HANA Databases

*External]*



*Customer Communication*

[Alert: Action Required] HQC_HANA Database Space

[image: Customer Communication]

Dear Customer,

*Customer Name:* NorthgateArinso Belgium BV

*CSS Incident: *31169 2024

Below alert was identified for the impacted system, as part of proactive
monitoring.

We analyzed the system and we need the following information/action from
you  to resolve this alert.



Alert Name: HANA Database Space



Analysis/Action Required:



This is regarding HQCNG0 system, we received an alert for HANA Data Volume
Usage.

As of now OS space utilization has reached up to 92% for HANA Data mount
point.



From database, we have looked for housekeeping and we couldn't find any old
database backups. Also, data volume reclaim is not possible.

Request customer to evaluate the options for archiving/deletions data based
on business requirements from EWA report. If that option not viable, then
request for additional storage.

Kindly find the below given details and provide approval to increase the
mount point by (AWS 500GB, NON-AWS 200GB) minimum to avoid a
database(default) full situation which can cause system outage.



Impact: There may be an impact on system performance / availability if
there is no action taken.



Please refer to the Incident mentioned in the Email for more details
regarding this alert and our recommendations to resolve the issue.



If there are any further details required about this alert/recommendation,
then please revert to us, or contact your SAP Enterprise Cloud Services
Representative.



*Product Name*

*Affected Entity*

SAP Enterprise Cloud Services

*System Number:*
500403881
*System ID:*
HQC
*System Role:*
Test System

SAP Enterprise Cloud Services

*System Number:*
500403881
*System ID:*
HQC
*System Role:*
Test System

Please refer to the attachment for more details.

*Questions?*

Please contact SAP Support using the Support Hotline
.";

var regex = /(?=Product Name)(.*?)(?=Please refer to the attachment for more details)/g;
var extractedValue = string.split(regex)[1];
gs.print('extractedValue: ' + extractedValue);

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, Robbie

Dhana1
Tera Contributor

Hi Robbie,

 

Thanks for your quick reply.

 

I have also tested via  regex101 working fine but when using the same regex in Event rule its populating empty values as below.

 

Dhana1_0-1728916490321.png

 

Can you help me with this

 

Hi @Dhana1,

 

No worries. Let's see if we can help. Just to confirm you saw my update to the post where you can further test this regex and extract it and assign it to a variable as shown via a 'Background script' - please confirm

 

Is there a particular event rule you're running this against or can you give the use case so I can try and replicate?

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, Robbie

Dhana1
Tera Contributor

Hi Robbie,

 

Thanks for your support.

 

I have tried in Background script and its working as expected, Please see the screenshot as below,

 

Dhana1_1-1728919128750.png

 

We have requirement to integrate SAP Cloud with Service Now via Event Management and we are using email methodology as they dont have an option through Rest API, Created an Inbound action and event rule to process it.

 

As we are getting different email formats to avoid breaking the integration didn't try regex script in Inbound Action to get the Product details in Alert Description so trying regex in Event rule to get those Product Name and Affected Entity details to populate in Alert Description & Incident description.

 

And those details we may use for CI Binding as populating CI data takes time for them so created an Business Service for each Environment so confused about how to implement this.

 

Even though we receive different email formats but each email body has Product Name and Entity details in order to capture System Number, ID, Role.

 

System No.System IDSystem NameInstallation NameSystem RoleSolution AreaDeployment TypeApp servicesBusiness Services
000000000xxxxxxxxxxxxxxxxxxxxxDevelopmentxxxxxxxPrivate CloudSAP Cloud DevSAP Enterprises

 

 

Example email subject and body pasted below,

 

Customer Communication

[Alert: Action Required] _xxxxx

 

 

 

 

Dear Customer,

Customer Name: NorthgateArinso Belgium BV

CSS Incident: 33371 2024

Below alert was identified for the impacted system, as part of proactive monitoring. 

 

We analyzed the system and we need the following information/action from you  to resolve this alert.

 

Alert Name: Degraded Resource Health

 

Analysis/Action Required: 

We could see server azure health status is degraded.

 

"The Physical Host in which your VM is running has potentially degraded memory. This could result in VM crashes or performance issues. Live Migration, if applicable, will be attempted as best effort to safely migrate your VM. We strongly recommend redeploying your VM to avoid unexpected disruptions."

 

Kindly check and provide 3 hours of downtime and 48 hours of lead time in below format to redeploy.

 

Date : dd/mm/yyyy

Start Time : 24 Hrs format

End time : 24 Hrs format

Time Zone:

Is the above time in 24 hour format: Yes/No

If no then confirm whether it is AM or PM

 

 

 

Impact: There may be an impact on system performance / availability if there is no action taken. 

Please refer to the Incident mentioned in the Email for more details regarding this alert and our recommendations to resolve the issue. 

If there are any further details required about this alert/recommendation, then please revert to us, or contact your SAP Enterprise Cloud Services Representative.

 

 

 

Product Name

Affected Entity

SAP Enterprise Cloud Services

System Number:
xxxxxxx
System ID:
xxxxx
System Role:
Production System

SAP Enterprise Cloud Services

System Number:
xxxxxxxx
System ID:
xxxxx
System Role:
Production System

Please refer to the attachment for more details.