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!

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 ...