Splunk Search

Quote escaping best practices

stevennoble
Explorer

I'm trying to figure out how I can format my logs such that splunk does not get confused by an escaped quote.
I'm currently doing something like

foo="a bunch of \"text\"" bar="a bunch \"more\" text"

And of course this quite confuses splunk. Assuming we don't want to switch to json how best to deal with quotes since backslash escaping doesn't seem to work.

Tags (2)
1 Solution

jtrucks
Splunk Employee
Splunk Employee

You will have to manually create field extractions to accommodate these logs. Once those are all configured and working, you shouldn't have to worry about auto-extracted fields with bad data. Check out KV_MODE in props.conf to disable auto-extracts for this source, too.

--
Jesse Trucks
Minister of Magic

View solution in original post

stevennoble
Explorer

Been playing with this. It appears KV_MODE = auto_escaped does everything I want

helge
Builder

This is the better answer

0 Karma

jtrucks
Splunk Employee
Splunk Employee

You will have to manually create field extractions to accommodate these logs. Once those are all configured and working, you shouldn't have to worry about auto-extracted fields with bad data. Check out KV_MODE in props.conf to disable auto-extracts for this source, too.

--
Jesse Trucks
Minister of Magic

stevennoble
Explorer

I don't mind escaping at search time. What I do mind is an extracted field of
foo: a bunch of

I can't change to single quotes because there are times where the single quote double quote distinction matters.

0 Karma

lukejadamec
Super Champion

If you use escape characters and quotes in your logs, then you will need to escape them both at search time.
If you don't wan't to escape quotes at search time, then use some a single quote in your logs.

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Where Innovation Takes Flight: The Splunk4Aviation Flight Sim Lands at .conf26

If you hear someone at .conf26 shouting "gear down, GEAR DOWN" across the show floor, you have found us.  The ...

Turn Cisco Telemetry Into Action with Cisco Data Fabric, powered by the Splunk ...

The surge in machine data is already hitting enterprise budgets, and the agentic era will only intensify it. ...

Persistent Queue at TcpOut — One of Splunk's Most Practical Features

Splunk introduced persistent queueing at the tcpout layer as one of the most practical resilience features in ...