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!

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Introducing the Splunk Community Dashboard Challenge!

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

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...