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!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...