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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...