Splunk Enterprise

Extracting multiline events into single line kv pairs.

JordanPeterson
Path Finder

So I have a script that we use to monitor our time drift on servers. The events look like this when ran:

server 10.0.1.187, stratum 4, offset 0.031839, delay 0.04155
server 10.0.1.188, stratum 5, offset -0.000584, delay 0.04158

How should I configure my props.conf and transforms.conf so I have nice clean field extraction?

So essentially each event is this but you may get 2-3 events per run of the script:

key value, key value, key value, key value

Update: I decided I was okay with search time extraction based on reading the props.conf documentation recommending this and so I have the following search:

basesearch | rex field=_raw "server (?<server>.*), stratum (?<stratum>.*), offset (?<offset>.*), delay (?<delay>.*)"

Which is fine if I only have one event but for multiline events it ignores all events after the first. How should I change this regex?

Tags (1)
0 Karma
1 Solution

xpac
SplunkTrust
SplunkTrust

Hey,

this regex should match those kind of events pretty well:
\s?([^\s,]+)\s([^\s,]+)(?:,|$)
regex101.com link

You could then create a stanza in props.conf for your sourcetype/host/source to match, and have it include:
REPORT-ntpevents = ntpevents

Then have transforms.conf like

[ntpevents]
REGEX = \s?([^\s,]+)\s([^\s,]+)(?:,|$)
MV_ADD = true
FORMAT = $1::$2

Hope that helps!

View solution in original post

xpac
SplunkTrust
SplunkTrust

Hey,

this regex should match those kind of events pretty well:
\s?([^\s,]+)\s([^\s,]+)(?:,|$)
regex101.com link

You could then create a stanza in props.conf for your sourcetype/host/source to match, and have it include:
REPORT-ntpevents = ntpevents

Then have transforms.conf like

[ntpevents]
REGEX = \s?([^\s,]+)\s([^\s,]+)(?:,|$)
MV_ADD = true
FORMAT = $1::$2

Hope that helps!

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