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
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...