I have configureda watcher to alert an event, when it happens it sends an email with Participant's SSN, Username, Ip address, Geolocation. The below action sends me the records.
But I want to mask the first 5 digits of the SSN and render XXX-XX-0000, something like this. Is there an easy way to do this?
If you have inline scripts allowed for your watchers, I'd recommend the following:
Create a transform script in PAINLESS (assuming a modern version of elastic stack) for your email action
The transform script would then reference your Participant SSN as a payload variable
The transform script would seperate the SSN into two groups, with the last4 being captured in a variable.
Return the variable as some string to the watch event already prepared in the desired format (XXX-XX-1234).
Reference that variable in your email template by the requisite name.
Obviously you'll want to play around with that; I don't have anything where I'm doing similar substitution but my idea was a transform to grab the last 4 digits from the SOC_SEC_NO, assign them to RegEx Variable 1, and to assign that as the last4SSN; Then concatenate that with the preceeding XXX-XX- to create a maskedSSN.
Return the variable for use in your email template as a mustache variable.
Use the watcher simulation to test your results, I recommend doing one transform statement at a time to ensure you're able to get it going!
I have another issue, where I want to show NA in email alert for the fields that are not available with _source. I have a pre-formatted email template for which the fields that are not available with _source, I have to show that as NA.
I have written a transform script like the one below. Is this the right way to do this? I am getting the below error for this script,
Please let me know if transform script is the right way to do this. If yes how can I access the returned value in email alert? If not, how can I achieve this.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.