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!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...