Splunk Search

Extract the second word with the events

prettysunshinez
Explorer

All,

I'm able to extract the second word but now the requirement is little different.

_time _raw
Shivera 346.789.63 is taking the second class 456.789.345,345.67.56
Shivera 345.786.66 now on the track class 56.78.67,-
Madura 456.190.45 shrewed it
aaruliya 455.67.30 top class calls 984.04.62 extra
Ghiya 495.81.22 tracking 627.85.79,34.56.78

Here in one event,there are different no. Of lines of logs.
And as i haved highlighted I would wanted to extract those alone.

How can i achieve it.

Thanks

Tags (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @prettysunshinez,
you could try something like this:

^\w+\s+(?<my_field>[^ ]*)

that you can test at https://regex101.com/r/B6ZNn4/1

Ciao and Merry Christmas.
Giuseppe

0 Karma

vnravikumar
Champion

Hi

Check this

| makeresults 
| eval temp="Shivera 346.789.63 is taking the second class 456.789.345,345.67.56#Shivera 345.786.66 now on the track class 56.78.67,-#Madura 456.190.45 shrewed it#aaruliya 455.67.30 top class calls 984.04.62 extra#Ghiya 495.81.22 tracking 627.85.79,34.56.78" 
| makemv delim="#" temp 
| mvexpand temp 
| rex field=temp "^[^\s]+\s+(?P<output>[0-9.]+)"

or

| makeresults 
| eval temp="Shivera 346.789.63 is taking the second class 456.789.345,345.67.56#Shivera 345.786.66 now on the track class 56.78.67,-#Madura 456.190.45 shrewed it#aaruliya 455.67.30 top class calls 984.04.62 extra#Ghiya 495.81.22 tracking 627.85.79,34.56.78" 
| makemv delim="#" temp 
| mvexpand temp 
| eval output =mvindex(split(temp," "),1)
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Agent Mode Engaged! Enchaining Agentic Operations with Splunk AI Assistant 2.0

    Are you ready to transform how your team handles complex data requests? We invite you to our upcoming ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...