Splunk Search

i just want to extract the number from the below sentance and replace with xxxx . Help me

DataOrg
Builder

the Information in service : ID R1-7857hi75 is duplicated

i want to make it as
the Information in service : ID R1-******* is duplicated

0 Karma
1 Solution

harsmarvania57
Ultra Champion

Hi @premranjithj,

If you want to anonymise during search time you use below query

< your search> | rex mode=sed "s/(?m)(\-)(\w+)/\1xxx/g

If you want to anonymise value during index time, please add below config on props.conf in Indexer or Heavy Forwarder whichever comes first.

props.conf

[yoursourcetype]
SEDCMD-maskvalue = s/(?m)(\-)(\w+)/\1xxx/g

I hope this helps.

Thanks,
Harshil

View solution in original post

harsmarvania57
Ultra Champion

Hi @premranjithj,

If you want to anonymise during search time you use below query

< your search> | rex mode=sed "s/(?m)(\-)(\w+)/\1xxx/g

If you want to anonymise value during index time, please add below config on props.conf in Indexer or Heavy Forwarder whichever comes first.

props.conf

[yoursourcetype]
SEDCMD-maskvalue = s/(?m)(\-)(\w+)/\1xxx/g

I hope this helps.

Thanks,
Harshil

DataOrg
Builder

@harsmarvania57. thanks its worked.
can you please explain me the expression. i just want to understand to form other expression

0 Karma

harsmarvania57
Ultra Champion

I am using sed mode in rex so in expression format is s/regexp/replacement/flags, in this format s means substitute then regex (?m)(\-)(\w+) (This will find data in (?m)->multiline with pattern - (-) in first capturing group (\w+) means word with any length in second capturing group) and replacement is \1xxx (Which will replace 2nd capturing group with xxx) and flag is g (Apply the replacement to all matches to the regexp, not just the first.)

For more explanation and play with regex with your sample data please refer https://regex101.com/r/HHefSs/1

Please accept my answer and upvote it, as it worked for you.

0 Karma

DataOrg
Builder

@harsnarvania57. thanks much for making me to understand. its really good

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...