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!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...