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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...