Splunk Search

Extract the fields user and service account

Hema_Nithya
Explorer
Dec 2 08:46:55 server1 sudo[3461907]: ib12345 : TTY=pts/0 ; PWD=/home/ib12345 ; USER=root ; COMMAND=/bin/su - webadmin
 
I would like to extract the upi  from above ib12345

upi  ib12345
service_account webadmin 
 
Sometime after is empty COMMAND=/bin/su - 
Labels (2)
Tags (2)
0 Karma

Hema_Nithya
Explorer

I tried this working 

| rex "COMMAND=\/[a-z]*\/[a-z]*\s-\s(?<service_account>[^ ]+)"
0 Karma

Hema_Nithya
Explorer

Hi Thanks 

I also want to extract another field from the below  data "webadmin" as service_Account COMMAND=/bin/su - webadmin

Dec 2 08:46:55 server1 sudo[3461907]: ib12345 : TTY=pts/0 ; PWD=/home/ib12345 ; USER=root ; COMMAND=/bin/su - webadmin

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Assuming your spacing is as shown in your example:

| rex "sudo\s*?:\s(?<upi>\S+)\s"
0 Karma
Get Updates on the Splunk Community!

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

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

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...