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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Event Series: Telemetry Pipeline Management

Balancing Scale and Spend: Gaining Control Over High-Volume Metrics in Splunk Observability Cloud As ...

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...

Deep insights, no barriers: Splunk Observability Cloud Free Edition

As software delivery cycles continue to accelerate, observability shouldn’t be a luxury — it should be a ...