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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...