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!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...