Knowledge Management

How do I calculate field in props.conf?

VijaySrrie
Builder

Hi 

I have extracted a field username and it has domain and user

username= "google\\john"
username="googleuser"
username = "admin"

I need calculated to be created in props.conf where google should go to domain and john should go to user field

This domain field will be there only in certain logs

So whatever is there before "\\" should be considered as domain and after "\\" is user
In some cases domain wont be there, for those cases username to be tagged to user field

All this should happeb at backend props.conf


domain = google

user= john
user = googleuser
user = admin

Labels (2)
Tags (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @VijaySrrie ,

you have to create another field extraction usig this regex

^((?<domain>\w+)\\\\)*(?<user>\w+) in user

that's the same thing to run the following command:

| rex field=user "^((?<domain>\w+)\\\\)*(?<user>\w+)"

you can test the regex at https://regex101.com/r/j6kC26/1

Ciao.

Giuseppe

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...