Splunk Search

How to extract a specific field (number "n") from an event

leifab
New Member

How to extract a specific field from an event, like "awk '{print $13}'", In this example I want to extract field 13 (22.4):

12345 0.0 0.0 90 -2.3 51 985.7 12.3 12.3 12.3 0.000 0.000 22.4 41 0.0 0 0.0 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 20 19 01

0 Karma
1 Solution

jpolvino
Builder

Here is one way to do it, using a Run Anywhere search:

| makeresults
| eval yourEvent="12345 0.0 0.0 90 -2.3 51 985.7 12.3 12.3 12.3 0.000 0.000 22.4 41 0.0 0 0.0 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 20 19 01"
| eval fields=split(yourEvent," ") | eval num=mvindex(fields,12)

num=22.4

View solution in original post

jpolvino
Builder

Here is one way to do it, using a Run Anywhere search:

| makeresults
| eval yourEvent="12345 0.0 0.0 90 -2.3 51 985.7 12.3 12.3 12.3 0.000 0.000 22.4 41 0.0 0 0.0 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 20 19 01"
| eval fields=split(yourEvent," ") | eval num=mvindex(fields,12)

num=22.4

Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

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