Getting Data In

How to extract new fields from a JSON array?

James_ACN
Loves-to-Learn Everything

Hi All!

How to extract and create different fields by transforms when there is an array (JSON) with several fields with the same name but different values?
For example, the "text" field in the first case means "action", in the second the "text" field means "hostname".
Just like "port" that appears twice would have to be identified as src_port and dst_port.

Sample_log_json.png

Sample:

"{ 
   detail: { 
      indicators: [
       { 
         filterId: [
         ]

         id1
         objectTypeport
         objectValue445
         relatedEntities: [
         ]

       }
       {
         filterId: [
         ]

         id2
         objectTypetext
         objectValueReset
         relatedEntities: [
         ]

       }
       {
         filterId: [
         ]

         id3
         objectTypeport
         objectValue36880
         relatedEntities: [
       ]
       }
       {

       filterId: [
         ]

         id6
         objectTypetext
         objectValueSERVERWIN01
         relatedEntities: [
         ]

       }
       { 
         filterId: [
         ]

         id7
         objectTypedetection_name
         objectValueMicrosoft Windows SMB Information Disclosure Vulnerability (CVE-2017-0147)
         relatedEntities: [
         ]

 
   }"


Thanks!

James 

Labels (3)
0 Karma

James_ACN
Loves-to-Learn Everything

Hi All!

I still haven't been able to solve this problem.

Does anyone have any outline suggestions?

 

Thanks!

 

James \°/

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Firstly, it looks like an output of spath command, not the automatic json extraction (the automatic extraction doesn't understand json structure and just uses "final" field names).

Secondly, how would you distinguish between different ports? You can of course retrieve specific value of multivalue field by mvindex() but are you sure that src port will always be firts value? And so on?

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 + Splunk! We’ve ...