Splunk Search

How to write the regex to split a single event to multiple events after a particular number of characters in a string?

jyothishtj
New Member

Hi,

I am trying to split an event to multiple events. I want to split after 12th character. The string contains space as well.
E.g,

aaaaa bbb aa aaaaa bcb aa accaa bbb aa.................................

I want to get aaaaa bbb aa as one event. aaaaa bcb aa as another event and so on

I tried with BREAK_ONLY_BEFORE and LINE_BREAKER parameters with different regular expressions, but not working. I gave SHOULD_LINEMERGE as false. Please help to create a way to achieve this.

Thanks,
Jyo

0 Karma
1 Solution

dart
Splunk Employee
Splunk Employee

Does:

LINE_BREAKER = .{12}()
SHOULD_LINEMERGE=false

Work?

Or possibly:

TRUNCATE=12

View solution in original post

songhyunho
New Member

What about this?

^.{12}\s(?P.{12})

0 Karma

jyothishtj
New Member

I tried this , but not working

0 Karma

songhyunho
New Member

Sorry. Use this.

|rex field = _raw "^(?P<field1>.{12})\s(?P<field2>.{12})"
0 Karma

songhyunho
New Member

I'm sorry. I forgot the code sample setting.

|rex field = _raw "^.{12}\s(?P<newfield>.{12})"
0 Karma

dart
Splunk Employee
Splunk Employee

Does:

LINE_BREAKER = .{12}()
SHOULD_LINEMERGE=false

Work?

Or possibly:

TRUNCATE=12

jyothishtj
New Member

I tried the first option. It is working. But the truncate is giving only the first 12 characters as a single event

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

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