Splunk Search

I'm looking to create a search query to analyze traffic to determine source / destination IP and source / destination port, as well as using timestamp?

rcastello
Explorer

Hello,

I'm currently using this query to create a table:

index=* sourcetype=* dport=139 OR sport=139
| eval timestamp=strftime(_time, "%B %d, %I:%M:%S %p") 
| table timestamp sourcetype dport sport

However, I'd like to include src_ip and dest_ip, so I tried this but it doesn't pull the same results:

index=* sourcetype=* src_ip=* dest_ip=* dport=139 OR sport=139
| eval timestamp=strftime(_time, "%B %d, %I:%M:%S %p") 
| table timestamp sourcetype src_ip dest_ip dport sport

What am I doing incorrectly and how can I reach my desired results? Thank you for any help provided.

Tags (1)
0 Karma

woodcock
Esteemed Legend

Try this:

index=* sourcetype=* dport=139 OR sport=139
| eval timestamp=strftime(_time, "%B %d, %I:%M:%S %p") 
| eval src=coalesce(src_ip, src, src*, "unknown")
| eval dest=coalesce(dest_ip, dest, dest*, "unknown")
| table timestamp sourcetype src dest dport sport
0 Karma

rcastello
Explorer

Hello woodcock,

Thanks for your assistance. When I utilize your recommendation, Splunk throws this error:

Error in 'eval' command: The expression is malformed. An unexpected character is reached at ', "unknown")'.

Is there some data I should be using in place of "unknown" instead? Thanks for your help, @woodcock .

0 Karma

ddrillic
Ultra Champion

It does seem that coalesce takes only two parameters...

Sorry, the documentation says

-- This function takes an arbitrary number of arguments and returns the first value that is not NULL.

0 Karma
Get Updates on the Splunk Community!

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...