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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...