Splunk Search

Extract data from within only double quotes "*" in a _raw log

chrisschum
Path Finder

How can you only extract data from a _raw log where the data I want is separated with double quotes? So it's "this is the only data I want"

Thanks!

Tags (1)
0 Karma

niketn
Legend

@chrisschum as far as I understand your intent is not to remove but to extract data from within quotes. While some more patter for identifying correct double quote to start the extraction would be useful, you can try out the following rex command to begin with:

| makeresults
| eval _raw="my sample raw data with text string... \"this is the only data I want\"... nothing else matters"
| rex "\"(?<myfield>[^\"]+)\""

Please try out and confirm. Once you have tested the rex with your sample data, you can move the same to Fields Extraction Knowledge Object, using Interactive Field Extraction or directly editing props.conf file.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

chrisschum
Path Finder

Thanks! That works. I have one followup question. In the "this is the only data I want" how do I make it so that data can be anything alphanumeric. So anything between the double quotes can be any data?

Thanks!

0 Karma

493669
Super Champion

The SEDCMD-* option in props.conf can be used to remove unwanted part of log entries.
You can refer here- http://docs.splunk.com/Documentation/Splunk/7.1.2/Data/Anonymizedata

[<YOURSourcetype Name>]
 SEDCMD-strip-detail-msg = s/^[^"]+//g

Please check Regex
its format is SEDCMD-<class> = s/<regex>/<replacement>/flags

0 Karma

chrisschum
Path Finder

Thanks! But I want to keep the log data, just extract the data between the double quotes.

0 Karma
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 ...