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!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...