Splunk Search

How to edit my search to make a table containing content from myField= until end of the line?

viggor
Path Finder

I have a log file where the last field contains space separated values and I would like to create a table containing the value of this last field, to the substring starting after myField=, and ending at the end of the line

an example log file would look like:

timestamp=2322 foo=bar myField=Hello pretty world

timestamp=2323 foo=joe myField=Good by moon

My desired result would be

Hello pretty world
Good by moon

I tried, unsuccessfully: | regex myField="$" as mySentence | table mySentence

Tags (4)
0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

YOu should be using rex command to capture/extract fields. Try like this

your base search | rex "myField=(?<mySentence>.*)$" | table mySentence

View solution in original post

somesoni2
SplunkTrust
SplunkTrust

YOu should be using rex command to capture/extract fields. Try like this

your base search | rex "myField=(?<mySentence>.*)$" | table mySentence

viggor
Path Finder

Thanks for your answer! It works well except if mySentence does not start with an alphanumerical character, do you have any idea why that is, since . should match against any character?

0 Karma

viggor
Path Finder

myField=RT @UMich: You can watch the panel

Would be an example where I only get RT stored in mySentence

0 Karma

michael_sleep
Communicator

Can you provide an example? . would indeed match any character.

0 Karma

gokadroid
Motivator

Can you please post your sample log line and what are you trying to extract from that log line. We can help thereafter.

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...