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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...