Splunk Search

How to use regex to extract field?

kiran331
Builder

HI How to extract the field with space using regex?

name:
T11345DDF ERROR
T11345SSDF Volume C

values:
123455-25335535-55454545-5656566-45655-36565656-6656-488656 TPM

I need to extract T11345DDF , T11345SSDF , 123455-25335535-55454545-5656566-45655-36565656-6656-488656

Tags (1)
0 Karma
1 Solution

gokadroid
Motivator

Let's say that it is always the first word in each event line then can you try this please:

your query to return events
| rex "^(?<myField>[^\s]+)\s*"
| table myField

See extraction here

View solution in original post

0 Karma

rbreton
Path Finder

If you need more flexibility you might need to create fields extractions. If it was me, I would create 3 separate field extractions.

- (?P<error>.*?)\sERROR
- (?P<volume>.*?)\sVolume
- (?P<tpm>.*?)\sTPM
0 Karma

gokadroid
Motivator

Let's say that it is always the first word in each event line then can you try this please:

your query to return events
| rex "^(?<myField>[^\s]+)\s*"
| table myField

See extraction here

0 Karma

kiran331
Builder

Thanks gokadroid.

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 ...