Splunk Search

How to use windcard with spcial charaters to trim a field

nirmalya2006
Path Finder

Hi All

I have a field which has urls in this pattern

GET /echo/index?page=content&id=PRO19579&viewlocale=es_ES HTTP/1.1  

I have to extract only the part "page=content" from it.
I tried to extract it using substr and rtrim but I am unable to trim contents after &.
My search string is

| eval URL = substr(field7,17) | eval URL = rtrim(URL,"^\\&*") 

Please help.

Tags (1)
0 Karma

davebrooking
Contributor

Given your example above, what should the field URL contain?

Dave

0 Karma

nirmalya2006
Path Finder

The field URL should contain "content".

0 Karma

sundareshr
Legend

Try regex (updated to include in code block the <url> shows correctly

  ..| rex " \?page=(?<url>[^&]+)" | ...
0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...