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

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...