Splunk Search

Regex question

gnovak
Builder

I can't seem to figure this one out. I have a line in a log like this:

2012-08-07 12:35:49,138 [http-10.40.231.33-40081-11] INFO info.mycompany.WAT.report.ReportService - USER [6913-ZZ] downloading /billing/2012/May/Statement.pdf

And here is my splunk search with regex:

sourcetype="EPPWEB" source="/opt/log//web_server/info.log" WAT | rex field=_raw "USER (?P[\d+-\w\w]) downloading /[^/]+/[^/]+/(?P\w.\w+)+$"

For the field "filename" i have results like ".pdf" or ".txt". I'd like to get the entire file name ....Statement.pdf

What am I missing or not missing?

Tags (1)
0 Karma
1 Solution

dmaislin_splunk
Splunk Employee
Splunk Employee

rex field=_raw "USER.*/(?.+?)$"

View solution in original post

0 Karma

dmaislin_splunk
Splunk Employee
Splunk Employee

rex field=_raw "USER.*/(?.+?)$"

0 Karma

dmaislin_splunk
Splunk Employee
Splunk Employee

Awesomeness!

0 Karma

gnovak
Builder

This actually worked. I took some of your example and added it. sourcetype="EPPWEB" source="/opt/log//web_server/info.log" WAT | rex field=_raw "USER (?P[\d+-\w\w])./(?.+?)$"

Thanks for the help

0 Karma

gnovak
Builder

sourcetype="EPPWEB" source="/opt/log/*/web_server/info.log" WAT | rex field=_raw "USER (?P[\d+-\w\w]) downloading /[^/]+/[^/]+/(?Pw+.w+).$" doesn't work. Even taking away the $ doesn't work either. 😞

0 Karma

christopher_hod
Path Finder

Try making the end look like this:
downloading /[^/]+/[^/]+/(?P[\w.])$"

0 Karma

gnovak
Builder

When I take the ending + away the field "filename" isn't extracted any more.

0 Karma

sdaniels
Splunk Employee
Splunk Employee

Maybe (?Pw+\.w+). Escape the period just to make sure.

0 Karma
Get Updates on the Splunk Community!

Splunk Enterprise Security: Your Command Center for PCI DSS Compliance

Every security professional knows the drill. The PCI DSS audit is approaching, and suddenly everyone's asking ...

Developer Spotlight with Guilhem Marchand

From Splunk Engineer to Founder: The Journey Behind TrackMe    After spending over 12 years working full time ...

Cisco Catalyst Center Meets Splunk ITSI: From 'Payments Are Down' to Root Cause in ...

The Problem: When Networks and Services Don't Talk Payment systems fail at a retail location. Customers are ...