Splunk Search

Field Extraction from space-aligned fields in multi-line events

landen99
Motivator

From events of the form:

Filesystem                  Type              Size        Used       Avail      UsePct    MountedOn
/dev/mapper/stuff1          ext4               50G        3.4G         44G          8%    /
/dev/mapper/stuff2          ext4              485M         86M        374M         19%    /boot
/dev/mapper/stuff3          ext4              926G        245M        879G          1%    /home
/dev/mapper/stuff4          ext4              9.9T        4.8T        4.7T         51%    /opt

These need to be accepted into fields and displayed in a chart.

0 Karma
1 Solution

landen99
Motivator
index=os sourcetype=df host="host11" |  rex max_match=4 field=_raw ".*?\n(?<Filesystem>[^F]\S+)\s+(?<Type>\S+)\s+(?<Size>\S+)\s+(?<Used>\S+)\s+(?<Avail>\S+)\s+(?<UsePct>\S+)\s+(?<MountedOn>\S+)"  | table _time Filesystem, Type, Size, Used, Avail, UsePct, MountedOn

View solution in original post

0 Karma

landen99
Motivator
index=os sourcetype=df host="host11" |  rex max_match=4 field=_raw ".*?\n(?<Filesystem>[^F]\S+)\s+(?<Type>\S+)\s+(?<Size>\S+)\s+(?<Used>\S+)\s+(?<Avail>\S+)\s+(?<UsePct>\S+)\s+(?<MountedOn>\S+)"  | table _time Filesystem, Type, Size, Used, Avail, UsePct, MountedOn
0 Karma

landen99
Motivator

Looks like multikv works too with much less regex knowledge, but the result has each line as a separate table entry:

index=os sourcetype=df host="host11" | multikv fields Filesystem Type Size Used Avail UsePct MountedOn | table _time Filesystem, Type, Size, Used, Avail, UsePct, MountedOn
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, ...