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 Observability Synthetic Monitoring - Resolved Incident on Detector Alerts

We’ve discovered a bug that affected the auto-clear of Synthetic Detectors in the Splunk Synthetic Monitoring ...

Video | Tom’s Smartness Journey Continues

Remember Splunk Community member Tom Kopchak? If you caught the first episode of our Smartness interview ...

3-2-1 Go! How Fast Can You Debug Microservices with Observability Cloud?

3-2-1 Go! How Fast Can You Debug Microservices with Observability Cloud? Learn how unique features like ...