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!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...