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!

How Edge Processor's Durable Queue Works

Edge Processor sits in one of the most consequential places in any Splunk pipeline: between your data sources ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Quantify Your Splunk Investment Impact: Introducing Savings Metrics to Value Insights

Building on the foundation established in our initial Value Insights releases, we are introducing the Savings ...