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!

Splunk Forwarders and Forced Time Based Load Balancing

Splunk customers use universal forwarders to collect and send data to Splunk. A universal forwarder can send ...

NEW! Log Views in Splunk Observability Dashboards Gives Context From a Single Page

Today, Splunk Observability releases log views, a new feature for users to add their logs data from Splunk Log ...

Last Chance to Submit Your Paper For BSides Splunk - Deadline is August 12th!

Hello everyone! Don't wait to submit - The deadline is August 12th! We have truly missed the community so ...