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!

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Your Voice Matters! Help Us Shape the New Splunk Lantern Experience

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

Building Momentum: Splunk Developer Program at .conf25

At Splunk, developers are at the heart of innovation. That’s why this year at .conf25, we officially launched ...