Splunk Search

Unable to extract IP Address and Port number with reg

RNB
Path Finder

I have an event that I want to extract the IP Address and Port number.

Mar 6 13:59:59 192.168.140.215 %ASA-4-106023: Deny udp src outside:xxx.xxx.xxx.xxx/xxxxx dst inside:xxx.xxx.xxx.xxx/xxxxx by access-group "outside_access_in" [0x0, 0x0]

The following search works and produces results.
(sourcetype=cisco_asa AND Deny NOT (search)) | rex field=Outside "outside:(?P[^/])(?P[^ ]*?)" | stats count by OutsideIP | sort -count

But this search works but does not produce any results.
(sourcetype=cisco_asa AND Deny NOT (search)) | rex field=Outside "outside:(?P[^/])(?P[^ ]*?)" | stats count by OutsidePort | sort -count

I have tried many variations to extract the OutsidePort with no success. What am I doing wrong?

Thank you
Randy

Tags (2)
0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

This works for me:

...  | rex "outside:(?<outside_ip>[^/]+)/(?<outside_port>\S+)" | stats count by outside_port

View solution in original post

s_linner
Engager

I think the only thing you forgot is the "/" between the extraction of "outsideip" and "outsideport", which martin_mueller has in his extraction...

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

This works for me:

...  | rex "outside:(?<outside_ip>[^/]+)/(?<outside_port>\S+)" | stats count by outside_port

RNB
Path Finder

I added the missing / between the round brackets to what I had but I still had problems. I kept fiddling with what I had unsuccessfully, but cutting & pasting exactly what you have does the job. Thank you.

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...