Splunk Search

How to rex extract two last word?

indeed_2000
Motivator

Hi how can I extract only last 2 word that exist in className

I have log like this:

2022-05-24 16:29:51,918 INFO [APP] [ActionName] className[xx.xx.xxx.xxxx.xxx.session.controller.SearchClusterFinancialTcpMBean.search] status[done]

2022-05-24 16:29:51,918 INFO [APP] [ActionName] className[xx.xx.xxx.xxxx.xxx.session.controller.SearchClusterFinancialTcpMBean.search.attribute] status[done]

 

excpected output:

SearchClusterFinancialTcpMBean.search

search.attribute

 

Any idea?

Thanks,

Labels (3)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

This regular expression should do it.

className\[.*?(?<lastTwo>[^\.]+\.[^\.]+?)]
---
If this reply helps you, Karma would be appreciated.

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
| rex "className.*\.(?<class>\w+\.\w+)\]"
0 Karma

richgalloway
SplunkTrust
SplunkTrust

This regular expression should do it.

className\[.*?(?<lastTwo>[^\.]+\.[^\.]+?)]
---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Splunk Enterprise Security 8.0.2 Availability: On cloud and On-premise!

A few months ago, we released Splunk Enterprise Security 8.0 for our cloud customers. Today, we are excited to ...

Logs to Metrics

Logs and Metrics Logs are generally unstructured text or structured events emitted by applications and written ...

Developer Spotlight with Paul Stout

Welcome to our very first developer spotlight release series where we'll feature some awesome Splunk ...