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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...