Splunk Search

handle ' as field delimiter in logs

dominiquevocat
SplunkTrust
SplunkTrust

I have logs that are generally fine and log in key=value pairs - however it uses a strage format
Sample:
rmIP='195.182.60.200'
splunk won't recognize it i.e. the field content in splunk is '195.182.60.200' as oposed to 195.182.60.200

how would i best go about it?

Tags (1)
0 Karma
1 Solution

emechler_splunk
Splunk Employee
Splunk Employee

You'll probably want to use REGEX / FORMAT for this. This regex might need some tuning, but it should handle the following cases:

rmIP='195.182.60.200'
rmIP="195.182.60.200"
rmIP=195.182.60.200

In transforms.conf:

[strip-quotes]
REGEX = ([^ ]+)=(?:\'|\")?([^\'\"\s]+)(?:\'|\")?
FORMAT = $1::$2

In props.conf:

[my_sourcetype]
REPORT-strip-quotes = strip-quotes

View solution in original post

sowings
Splunk Employee
Splunk Employee

You could use an eval-based rule (see "EVAL" in props.conf documentation), to invoke 'trim', keeping the old field name:


EVAL-rmIP = trim(rmIP, "'")

0 Karma

emechler_splunk
Splunk Employee
Splunk Employee

You'll probably want to use REGEX / FORMAT for this. This regex might need some tuning, but it should handle the following cases:

rmIP='195.182.60.200'
rmIP="195.182.60.200"
rmIP=195.182.60.200

In transforms.conf:

[strip-quotes]
REGEX = ([^ ]+)=(?:\'|\")?([^\'\"\s]+)(?:\'|\")?
FORMAT = $1::$2

In props.conf:

[my_sourcetype]
REPORT-strip-quotes = strip-quotes

dominiquevocat
SplunkTrust
SplunkTrust

I ended up doing regex to extract the information into (CIM like) normalized fields. But this would have worked nicely and seems a good solution for most encountering this situation. It would be nice if splunk's internal regex would also automatically recognize ' as field content delimiter.

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...