Splunk Search

rex during search convert to transforms/props during indexing help

jtm7x2
Explorer

Hello.  I have a data source that is "mostly" json formatted, except it uses single quotes instead of double, therefore, splunk is not honoring it if I set the sourcetype to json.

If I run a query against it using this:

sourcetype="test" | rex field=_raw mode=sed "s/'/\"/g"
| spath

it works fine, and all fields are extracted.

How can I configure props and transforms to perform this change at index time so that my users don't need to have the additional search parameters and all the fields are extracted by default, short of manually extracting each field?

Example event, no nested fields:

{'date': '2024-02-10', 'time': '18:59:27', 'field1': 'foo', 'field2': 'bar'}

Labels (1)
0 Karma
1 Solution

jtm7x2
Explorer

Thanks.  I got it to work, but had to modify the syntax slightly to remove the backslashes - this worked.

[yoursourcetype]
SEDCMD-singletodouble=s/'/"/g

 

View solution in original post

0 Karma

marnall
Motivator

You can use a SEDCMD to replace all the single quotes with double-quotes before indexing.

in Props.conf:

[yoursourcetype]
SEDCMD-singletodouble=s/\'/\"/g

jtm7x2
Explorer

Thanks.  I got it to work, but had to modify the syntax slightly to remove the backslashes - this worked.

[yoursourcetype]
SEDCMD-singletodouble=s/'/"/g

 

0 Karma
Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...