Getting Data In

SEDCMD to alter text - Redacting

KeithH
Path Finder

Hi All,

I have events with text strings like this:

    ..._Code/> <InDesc>Diagnosis=Read Code,Comment=carrying | ladder and triped and  fell hurt  L Shoulder / upper back- issues is pain,DiagnosisSide=right</InDesc> <First_Name...

I want to redact the blue text and can easily do so with this sort of thing:

    SEDCMD-test = s/(<InDesc>)[^<]+/\1Splunk_Redacted/g

Giving a result like:

   ..._Code/> <InDesc>Splunk_Redacted</InDesc> <First_Name..

BUT I would prefer to retain the structure of the blue text (i.e. replace the digits with 9 and the letters all with A or a but leaving the rest.    I can do that part individually like this:

echo "Diagnosis=Read Code,Comment=carrying | ladder and triped and  fell hurt  L Shoulder / upper back- issues is pain,DiagnosisSide=right" | sed y/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/aaaaaaaaaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAAAAAA9999999999/

And getting this output

Aaaaaaaaa=Aaaa Aaaa,Aaaaaaa=aaaaaaaa | aaaaaa aaa aaaaaa aaa  aaaa aaaa  A Aaaaaaaa / aaaaa aaaa- aaaaaa aa aaaa,AaaaaaaaaAaaa=aaaaa

But how can I combine them both to achieve this output: 

   ..._Code/> <InDesc>Aaaaaaaaa=Aaaa Aaaa,Aaaaaaa=aaaaaaaa | aaaaaa aaa aaaaaa aaa  aaaa aaaa  A Aaaaaaaa / aaaaa aaaa- aaaaaa aa aaaa,AaaaaaaaaAaaa=aaaaa</InDesc> <First_Name..

Any thoughts would be much appreciated.

 

Thanks, Keith

Labels (2)
Tags (2)
0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...