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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...