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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...