Splunk Search

How to Extract the data after second special character?

Neel881
Path Finder

Hello,

I want the extract everything after the second slash(/) 

OR

Everything from the last till the first slash (/)     -- Both scenario works for me

 

Example - 

generation/abcd/giveandtake-messages-to-s

generation/xyz/giveandtake-messages-speedline-s

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| rex ".+/.+/(?<message>.*)"

View solution in original post

Neel881
Path Finder

Perfect! Thanks

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex ".+/.+/(?<message>.*)"

PickleRick
SplunkTrust
SplunkTrust

Restricting the firs two strings to character classes

[^/]+/[^/]+/(?<message>.*)

 gives big performance boost (prevents backtracking).

Neel881
Path Finder

Thank you! 

Can we do from the end as well? Right to left till the special charater?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
/(?<message>[^/]+)$

PickleRick
SplunkTrust
SplunkTrust

If you want to capture everything after the last slash, you can do something like

.*/(?<message>[^/]*)$

 

Get Updates on the Splunk Community!

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

(view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...