Splunk Search

How to use rex to remove "domain\' from a username?

pil321
Communicator

I have a field that looks like this:

UserName=domain\joe_user

I want it to look like this:

UserName=joe_user

How do I take out domain\ using rex?

0 Karma
1 Solution

somesoni2
Revered Legend

Try this

your base search | rex field=UserName "\w+\\(?<UserName>.*)"

OR

your base search | eval UserName=mvindex(split(UserName,"\\"),-1)

View solution in original post

Dev_Choudhary
Path Finder

try this

rex field=cs_userdn "\w+\\(?\S+)"

0 Karma

woodcock
Esteemed Legend

Like this:

... | rex field=UserName mode=sed "s/[^\\\]*\\\//"
0 Karma

somesoni2
Revered Legend

Try this

your base search | rex field=UserName "\w+\\(?<UserName>.*)"

OR

your base search | eval UserName=mvindex(split(UserName,"\\"),-1)
Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...