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!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...