We are trying to implement custom javascript enrichment to the enrichment process hosted in a GCP pipeline.
Here is a verbal eg for what we are trying to achieve.
We would like to modify user_ipaddress field in 2 ways based on the value of another field of the event.
Similar to ip_annon enrichment, we want to mask the last n octets of the user_ipaddress.
Mask the entire user_ipaddress .
Is it possible to achieve this by modifying the user_ipaddress field in place like we have for ip_annon without having to add a custom schema for the updated value in bigquery?
Hey @ashish_george. Yes, it’s totally doable. You would need to use the setter to amend the canonical field, namely setUser_ipaddress(). That is, depending on the value of user_ipaddress, which you can obtain with the getter getUser_ipaddress(), you would set the new value like this:
where some_modified_value is your new value you want to assign to user_ipaddress depending on its original value.
Note that you do not need to return anything in process(event) function as you do not want any derived context. Using setters overrides the original values in event’s TSV. Thus, be extra careful as you won’t be able to restore the original values.
Hi @ashish_george , there are 2 issues that I could spot. I can see wrong quotes in your configuration, which could be simply copy/paste problem in your comment than the actual content of the configuration file.
For example, you are using “curly” quotes instead of straight quotes around schema and data properties. For better visibility, here’s the image that demonstrates it better
Secondly, your base64 encoded string needs to end in one or two equal sign (it least that was an issue in the past to my knowledge). That is, if you add a new line to your unencoded function, the encoded version will get it with an equal sign (or two). Something like this