Splunk Search

How to use rex to isolate fields with double quotes?

Foss
Engager

Hello I am trying to isolate 'msg' field with multiple quotes and when I use rex is either cannot grab what I need or it continues through the data and doesn't stop, thanks!

outcome="Success"msg="The "Account is trusted for delegation" property was modified from No to Yes"cs3="

I have tried | rex field=_raw "msg=\"(?<msg>[^\"]+)" with no success.

Labels (1)
Tags (2)
0 Karma
1 Solution

yuanliu
SplunkTrust
SplunkTrust

If you cannot predict how many quotes will appear in this "field", there  is no general solution.  Your best bet is to bet on that "cs3=" will follow "msg" field.

| rex "msg=\"(?<msg>.+)\"\s*cs3="

If that is not the case, you can try matching exactly even (0, 2, 4, ...) quotes inside quotes, like

| rex "msg=\"(?<msg>([^\"]+\"){0,2,4}[^\"]+)\""

 

View solution in original post

yuanliu
SplunkTrust
SplunkTrust

If you cannot predict how many quotes will appear in this "field", there  is no general solution.  Your best bet is to bet on that "cs3=" will follow "msg" field.

| rex "msg=\"(?<msg>.+)\"\s*cs3="

If that is not the case, you can try matching exactly even (0, 2, 4, ...) quotes inside quotes, like

| rex "msg=\"(?<msg>([^\"]+\"){0,2,4}[^\"]+)\""

 

Foss
Engager

thank you for the feedback, that worked nicely!

0 Karma
Get Updates on the Splunk Community!

Insights from .conf 2025, Smart Edge Processor Scaling, and a New Splunk Lantern ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Machine Learning - Assisted Adaptive Thresholding

Let’s talk thresholding. Have you set up static thresholds? Tired of static thresholds triggering false ...

Observability Unlocked: Kubernetes Monitoring with Splunk Observability Cloud

  Ready to master Kubernetes and cloud monitoring like the pros?Join Splunk’s Growth Engineering team for an ...