Splunk Search

How do I extract fields in line separated data without key-value pair?

melonman
Motivator

Hi,

I have a logfile containing data that looks like the below:

Nov 21 13:59:41
hostname1
data1
data2
data3
Nov 21 13:59:42
hostname1
data1
data2
data3
Nov 21 13:59:43
hostname1
data1
data2
data3

I would like to extract hostname, and each data in a separate line.
How can I configure the regex to get such fields?

Thanks in advance,

Tags (2)
0 Karma
1 Solution

sbrant_tt
Explorer

Splunk should already parse out each section, splitting on the timestamp, to a separate "record". This regex will work for the sample you've provided:

rex "(?m)(?.+)\n(?.+)\n(?.+)\n(?.+)\n(?.*+)"

View solution in original post

sbrant_tt
Explorer

Splunk should already parse out each section, splitting on the timestamp, to a separate "record". This regex will work for the sample you've provided:

rex "(?m)(?.+)\n(?.+)\n(?.+)\n(?.+)\n(?.*+)"

melonman
Motivator

That's great, thanks!

0 Karma
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

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