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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...