Splunk Search

How to edit the eval statement in my search to group URLs?

deepak312
Explorer

I have hundreds of URLs in my logs like below:

'GET /service/product/details '
'POST /service/product/eligibile '
'POST /service/tour/details '

I want to group these as per feature. Right now, my search is something like this:

eval FEATURE_NAME=case(url=="'POST /service/product/eligibile '" OR url=="'GET /service/product/details '", "PRODUCT_SERVICE", url=="'POST /service/tour/details '", "TOUR_SERVICE" | table FEATURE_NAME

When I have like 30 URLs from one service, the search becomes huge. Can someone please help if we can do some matching like get all "*/product/*" collected in "PRODUCT_SERVICE"?

0 Karma
1 Solution

cmerriman
Super Champion

you could probably do an eval

|eval PRODUCT_SERVICE=match(url,"\/product\/")
|eval TOUR_SERVICE=match(url,"\/tour\/")
|eval FEATURE_NAME=case(isnotnull(PRODUCT_SERVICE),"PRODUCT_SERVICE",isnotnull(TOUR_SERVICE),"TOUR_SERVICE")

a case might work

|eval FEATURE_NAME=case(match(url,"\/product\/"),PRODUCT_SERVICE,match(url,"\/tour\/"),TOUR_SERVICE)

View solution in original post

sundareshr
Legend

Why not use makemv & mvindex instead. Like this

| makemv url delim="/" 
| eval url1=upper(mvindex(url, 2)."_".mvindex(url, 1)) 
| table url url1

Here is a run-anywhere sample with your data

| makeresults 
| eval url="POST /service/product/eligibile;GET /service/product/details;POST /service/tour/details" 
| makemv url delim=";" 
| mvexpand url 
| makemv url delim="/" 
| eval url1=upper(mvindex(url, 2)."_".mvindex(url, 1)) 
| table url url1
0 Karma

cmerriman
Super Champion

you could probably do an eval

|eval PRODUCT_SERVICE=match(url,"\/product\/")
|eval TOUR_SERVICE=match(url,"\/tour\/")
|eval FEATURE_NAME=case(isnotnull(PRODUCT_SERVICE),"PRODUCT_SERVICE",isnotnull(TOUR_SERVICE),"TOUR_SERVICE")

a case might work

|eval FEATURE_NAME=case(match(url,"\/product\/"),PRODUCT_SERVICE,match(url,"\/tour\/"),TOUR_SERVICE)
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...