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!

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

(view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...

Adoption of Infrastructure Monitoring at Splunk

  Splunk's Growth Engineering team showcases one of their first Splunk product adoption-Splunk Infrastructure ...