Splunk Search

Field extraction from pre-defined text

mbasharat
Contributor

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
Contributor

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!

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...