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!

Detecting Remote Code Executions With the Splunk Threat Research Team

WATCH NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If exploited, ...

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

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

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...