Splunk Search

Field extraction from pre-defined text

mbasharat
Builder

I have a text file in below format. We are monitoring this file in Splunk. This file has like entries in new lines with different values but in exact same format. This data is a fixed format already defined.

fR0226672024ABCOL41333311023S02315201801 UID03

I need to extract data based on the position labeled in fields properly as below. Using sample data above. Th actual sample is different and I will adjust as needed. I need to have the foundation work.

f: Center Code
R: Mode
0226672024: ID
ABC: Application
OL: Source Code
41333311023: Version
S0: Department
23: Day
10: Month
2018: Year
01: Sequence
(>>): Two spaces for position
UID03: UID

How to have it extracted in above manner. Thanks in-advance!!!!

Tags (1)
0 Karma
1 Solution

nabeel652
Builder

Assuming all your fields are of fixed length across all events, this regex whould work in the field extractions

^(?<CentreCode>\w)(?<Mode>\w)(?<ID>\d{10})(?<Application>\w{3})(?<SourceCode>\w{2})(?<Version>\w{11})(?<Department>.{2})(?<Day>\d{2})(?<Month>\d{2})(?<Year>\d{4})(?<Sequence>.{2})\s+(?<UID>.*)$

View solution in original post

nabeel652
Builder

Assuming all your fields are of fixed length across all events, this regex whould work in the field extractions

^(?<CentreCode>\w)(?<Mode>\w)(?<ID>\d{10})(?<Application>\w{3})(?<SourceCode>\w{2})(?<Version>\w{11})(?<Department>.{2})(?<Day>\d{2})(?<Month>\d{2})(?<Year>\d{4})(?<Sequence>.{2})\s+(?<UID>.*)$

mbasharat
Builder

salam @ nabeel652,

with slight adjustment in use case, this worked with fixed position. THANKS!!! I have another challenging situation come up yesterday for RegEx. Will be posting a separate question tonight.

0 Karma

nabeel652
Builder

Wa'salam brother. Glad it helped!

0 Karma

nabeel652
Builder

are the fields like ID and SourceCode or Version of same length in each event?

0 Karma
Get Updates on the Splunk Community!

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

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...