Splunk Search

Can you help me extract some data with regex?

dbcase
Motivator

Hi,

I have this data

{"method":"GET","url":"/rest/icontrol/logout","params":{},"requestStartTime":1548363789220,"responseStatus":401,"success":false,"responseTime":1548363789372}   

--and--

{"method":"DELETE","url":"/rest/abortasync/icontrol/sites/630555/abortdeltas","params":{"spsId":95645},"requestStartTime":1548363788415,"responseStatus":401,"success":false,"responseTime":1548363788699}

I need to extract the logout from the first event and abortdeltas from the second event. Essentially the word after the last forward slash or the word before params

Any thoughts?

Tags (2)
0 Karma
1 Solution

Vijeta
Influencer

You can use something similar as in my example search-

|makeresults| eval x1="/rest/icontrol/logout" | appendpipe[|eval x1="/rest/abortasync/icontrol/sites/630555/abortdeltas"]| rex field=x1 "\/rest\S+\/(?<word>\S+)"

View solution in original post

0 Karma

dbcase
Motivator

I got the below to work in regex101 but it doesn't work in splunk

^(.*[\\\/])(?<lword>)\w+
0 Karma

dbcase
Motivator
index="wholesale_app" analyticType=CustomAnalytic Properties.index=33  false|regex "^(.*[\\\/])(?<lword>)\w+"|stats count by lword

The above doesn't work

0 Karma

Vijeta
Influencer

You can use something similar as in my example search-

|makeresults| eval x1="/rest/icontrol/logout" | appendpipe[|eval x1="/rest/abortasync/icontrol/sites/630555/abortdeltas"]| rex field=x1 "\/rest\S+\/(?<word>\S+)"
0 Karma

Vijeta
Influencer

@dbcase - If you are not sure of word rest in your data, you can just use rex field=x1 "\/\S+\/(?<word>\S+)

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...