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

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...