Splunk Search

Help with extracting specific data

Reosoul
New Member

Given bunch of results in a format like:

6d2112effbe814f41ef6a6b984221c2490ef5112b70d394c074bb1427561556c some.site.com REST.GET.OBJECT text/2015/xml/somefile.xml "GET /some.site.com/text/2015/xml/somefile.xmll?Expires=1479754790 HTTP/1.1" 200 - 24583 24583 27 26 "-" "-" -

How can I return only:

/some.site.com/text/2015/xml/somefile.xmll?Expires=1479754790

(in other words from: /some.site.com/ all the way till the next white space)?

Thanks.

0 Karma
1 Solution

maciep
Champion

Well, if the format is consistent, then something like this should work

your base search | rex "GET\s+(?<cool_field>\S+)"

Essentially find in the raw data where there is GET followed by a space (or spaces), then capture everything that is not a space after that and store it in a new field called "cool_field"

If the events are not in a consistent enough format where that would work, then maybe include some of the events where it doesn't work too and I'm sure we can adjust

View solution in original post

maciep
Champion

Well, if the format is consistent, then something like this should work

your base search | rex "GET\s+(?<cool_field>\S+)"

Essentially find in the raw data where there is GET followed by a space (or spaces), then capture everything that is not a space after that and store it in a new field called "cool_field"

If the events are not in a consistent enough format where that would work, then maybe include some of the events where it doesn't work too and I'm sure we can adjust

Reosoul
New Member

Great that worked! If within that cool_field I have some events that end with .jpg or .jpeg, is there a way to filter those out?

0 Karma

maciep
Champion

Not sure I understand exactly where they would be since the field ends with the expires part, but something like this should remove anything .jpg in that field

 your base search | rex "GET\s+(?<cool_field>\S+)" | rex field=cool_field mode=sed "s/\.jpe?g//g"

The sed mode of the rex command can be used for replacing strings. In this case, I'm looking for anything .jp(e)g and replacing it with nothing...and that's done (g)lobally in that field.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

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

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...