Splunk Search

extract ip username

dbashyam
Explorer

Hi, I am trying to extract the following 

[04 May 2021 13:13:59,786] [Nsh-Proxy-Thread-93] [INFO] [abc@abc.com:abc:10.123.123.123] [BLSSOPROXY] Connected to sm478383922 with a socket descriptor 304

I want to extract the "[abc@abc.com:abc:10.123.123.123]" and destination "sm478383922" put it in a table form

UsernameGroupSrc IpDestination
abc@abc.comabc10.123.123.123sm478383922

 

can you guys help me how to achieve this in splunk search?

Labels (1)
Tags (1)
0 Karma
1 Solution

aasabatini
Motivator

Hi @dbashyam 

try this on your search

| rex field=_raw "(?<username>\w+@\w+.\w+):(?<group>\w+):(?<ip>\d+\.\d+.\d+.\d+)(?:[^:\n]*Connected){1}\s+\w+\s+(?<destination>\w+)"
“The answer is out there, Neo, and it’s looking for you, and it will find you if you want it to.”

View solution in original post

dbashyam
Explorer

Thanks you so much. It worked like a charm

0 Karma

aasabatini
Motivator

Hi @dbashyam 

try this on your search

| rex field=_raw "(?<username>\w+@\w+.\w+):(?<group>\w+):(?<ip>\d+\.\d+.\d+.\d+)(?:[^:\n]*Connected){1}\s+\w+\s+(?<destination>\w+)"
“The answer is out there, Neo, and it’s looking for you, and it will find you if you want it to.”

dbashyam
Explorer

@aasabatini  if I have any other string apart from "Connected", like copy, connecting, failed to connect etc., is there a way to add that condition? I tried the pipe symbol (for or) but it did not work

 

| rex field=_raw "(?<username>\w+@\w+.\w+):(?<group>\w+):(?<ip>\d+\.\d+.\d+.\d+)(?:[^:\n]*Connected){1}\s+\w+\s+(?<destination>\w+)"

 

0 Karma
Get Updates on the Splunk Community!

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...