Splunk Search

How do I extract the latest occurrence of a field from multiple lines?

nkchaitanya
Explorer

Want to capture the latest occurrence of "working_condition_check - status -" which is "Stopped".

Please help me in getting the regex.

Below is the log message.

10/01/2018 15:01:04 Server_Name
working_condition_check - status - Started
working_condition_check - status - Running
working_condition_check - status - Stopped

0 Karma

harishalipaka
Motivator

hi @nkchaitanya

As @493669 answer follow that end of your query add this

| makeresults |eval hari="working_condition_check - status - Stopped" |rex field=hari ".*status - (?<status>\w+)" |where status="Stopped"
Thanks
Harish
0 Karma

493669
Super Champion

Hi @nkchaitanya,
Try this:

...|rex ".*status - (?<status>\w+)"
0 Karma
Get Updates on the Splunk Community!

Build Scalable Security While Moving to Cloud - Guide From Clayton Homes

 Clayton Homes faced the increased challenge of strengthening their security posture as they went through ...

Mission Control | Explore the latest release of Splunk Mission Control (2.3)

We’re happy to announce the release of Mission Control 2.3 which includes several new and exciting features ...

Cloud Platform | Migrating your Splunk Cloud deployment to Python 3.7

Python 2.7, the last release of Python 2, reached End of Life back on January 1, 2020. As part of our larger ...