Splunk Search

How to write rex so command can extract the fields from json data?

manjunath_n
Engager

hello,

Please help me with the rex commands for extracting the below fields from the json data.

"resourceName" : "abcd",
"hostname" : "ipvalue",
"environment" : "development"

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

 

| rex "resourceName\"\s:\s\"(?<resourceName>[^\"]+)\""
| rex "hostname\"\s:\s\"(?<hostname>[^\"]+)\""
| rex "environment\"\s:\s\"(?<environment>[^\"]+)\""

Alternatively, since it is JSON, why not use spath?

 

0 Karma
Get Updates on the Splunk Community!

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco &#43; Splunk! We’ve ...