Splunk Search

Need help with field-extractions on these events

gabrieldiasrosa
New Member

I have the following value:

Events
X|0001|NAME|PHONE
X|0002|NAME|ADDRESS|INFO1|INFO2

Based on the type (0001 or 0002) I want to extract different fields, is it possible ?

Can I split the event value based on a common separator (pipe) ?

0 Karma

cpetterborg
SplunkTrust
SplunkTrust

You can extract all the fields with this regex:

^(?P<f1>[^|]*)\|(?P<f2>[^|]*)\|(?P<name>[^|]*)\|((?P<phone>[^|]*)|((?P<address>[^|]*)\|(?P<info1>[^|]*)\|(?P<info2>[^|]*)))$

You will have to change the field names as you wish them to be, but it will extract the fields from either the first or second example lines. It's also fairly efficient.

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...