Splunk Search

Unable to mask data using Regex

Splunk Employee
Splunk Employee

I'm testing the data-mask feature by anonymizing the numbers in the brackets: splunk[9085] but it's not working
Is my regex expression incorrect? (generated using an online tool - https://regex101.com/)
Guide: https://docs.splunk.com/Documentation/Splunk/6.1.4/Data/Anonymizedatausingconfigurationfiles

Sample Log:
Aug 12 09:22:00 forwarder splunk[9085]: #011Checking default conf files for edits...

Forwarder configurations:

TRANSFORMS-anonymize = dhclient-anonymizer

REGEX = splunk\[(\d+)\]
FORMAT = $1splunk[####]$2
DEST_KEY = _raw

Tags (2)
0 Karma

Re: Unable to mask data using Regex


First of all you are using $1 and $2 in FORMAT. Every $n represents exactly one capture group in your REGEX. So in your FORMAT you use one capture group more than in your REGEX. That can't work obviously. You don't want to capture what you want to change. You want to capture what you want to keep. So what you probably want to do is using something like this.

REGEX = (.*splunk\[)\d+(\].*)
FORMAT = $1####$2

I tested it and it worked.

View solution in original post

0 Karma