Splunk Search

When trying to display field values, why are values being truncated after an apostrophe appears in the string?

adamblock2
Path Finder

I am currently trying to write a search which will, after specific conditions are met, display the subject field values of email logs. If/when the subject contains an apostrophe, only the text up to and including the apostrophe is displayed.

If the subject field appears as follows:

subject='There's a secret you should know about'

I want to finish the search with the statement

|table subject,_raw

or

|stats values(subject)

The only text that is returned is 'There'

Is there a way that the complete field value can be displayed?

Thank you.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

The problem is you have an odd number of un-escaped quotation marks (a.k.a. 'apostrophe') in that field. The best solution is to change how the field is written so it puts double-quotes ('"') around the field or escapes the single quote. If that's not possible, you may have to use rex on _raw to parse out the subject field yourself.

... | rex "subject='(?<subject>.*?)' foo=" | ...

where 'foo' is the name of the field that follows subject.

---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Community Content Calendar, November Edition

Welcome to the November edition of our Community Spotlight! Each month, we dive into the Splunk Community to ...

October Community Champions: A Shoutout to Our Contributors!

As October comes to a close, we want to take a moment to celebrate the people who make the Splunk Community ...

Stay Connected: Your Guide to November Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...