Splunk Search

How to extract JSON format using rex command?

karthi2809
Builder

How to extract JSON format using rex command, removing double quotes & semi colon?

"TranID":"a2775f5d", "TranStartTime":"2017-08-14T05:19:22.939-04:00", "TranEndTime":"2017-08-14T05:19:22.961-04:00"

When I extract

rex field=_raw "TranStartTime\S\S\S(?[^ ]+)"

2017-08-14T07:15:53.919-04:00",

Actually I need:

2017-08-14T07:15:53.919-04:00

Tags (4)
0 Karma

somesoni2
Revered Legend

Try like this

... | rex field=_raw "TranStartTime\"\:\"(?<TransStartTime>[^\"]+)"

ddrillic
Ultra Champion

@somesoni2, this worked perfectly fine, but trying to rex from the json field didn't work for us. Something like - | rex field=TranStartTime "<regular expression>"

Anything we miss here?

0 Karma

somesoni2
Revered Legend

You're running your rex on field TranStartTime , is it already extracted/available???

0 Karma

ddrillic
Ultra Champion

right, it's available as a field.

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to July Tech Talks, Office Hours, and Webinars!

What are Community Office Hours?Community Office Hours is an interactive 60-minute Zoom series where ...

Updated Data Type Articles, Anniversary Celebrations, and More on Splunk Lantern

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

A Prelude to .conf25: Your Guide to Splunk University

Heading to Boston this September for .conf25? Get a jumpstart by arriving a few days early for Splunk ...