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!

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...