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!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

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

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...