Splunk Search

rex for capturing up to 2 levels

xvxt006
Contributor

Hi,

we have uris in the below format. i want to capture only up to 2 levels (if it does not have 2 levels it should show what it has. for example xxxx in the first uri example) and i have used below rex expression but it still gets all the levels. Any help is appreciated

rex field=uri_path "/(?.[/.])(?:[\s/])

/xxxx
/xxxx/yyy
/xxxx/yyy/zzzz/

Tags (1)
0 Karma
1 Solution

somesoni2
Revered Legend

try this

| rex field=uri_path "/(?<uri_path1>\w+(\/\w+){0,1})"

View solution in original post

somesoni2
Revered Legend

try this

| rex field=uri_path "/(?<uri_path1>\w+(\/\w+){0,1})"

xvxt006
Contributor

Thx. it worked

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 ...