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!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...