Splunk Search

How to extract and download a field of array from an event?

New Member

I have an event which is constructed like the following:


   name: string,
   time: string,
   duration: string,
   logs: JSONObjects[]


When I download the event, I just want the logs which is everything inside [] but without the head part which is "{logs:" and the last "}"

To do that how do I construct the search query? 

Labels (1)
Tags (2)
0 Karma

Splunk Employee
Splunk Employee

Hi, you could use something like spath to process the json and then pick the logs array out of the resultant object.  Maybe something like this:

| eval json="{\"name\":\"json_name\", \"logs\":[{\"name\":\"log1\"}, { \"name\":\"log2\"}]}",

I added a second example with output_log_names to show how you would extract particular fields within the array json into their own multivalued field. 





0 Karma
Get Updates on the Splunk Community!

Routing Data to Different Splunk Indexes in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. The OpenTelemetry project is the second largest ...

Getting Started with AIOps: Event Correlation Basics and Alert Storm Detection in ...

Getting Started with AIOps:Event Correlation Basics and Alert Storm Detection in Splunk IT Service ...

Register to Attend BSides SPL 2022 - It's all Happening October 18!

Join like-minded individuals for technical sessions on everything Splunk!  This is a community-led and run ...