Splunk Search

How to create a table from indexed nested array

nordstromemg
New Member

I have been banging my head against the wall for a while and would love some help. Imagine I have the two event logs and would like to create a table from them. The logs have an array value and I want the last item in that array and I want the message value. Additionally, I want a top-level from each event. So if I have the following two logs.

Event Log 1:

{
  "description": "My description",
  "param.response.tracking": [
    {
        "message": "My message"
    },
    {
        "message": "My other message"
    }
  ]
}

Event Log 2:

{
  "description": "My description 1",
  "param.response.tracking": [
    {
        "message": "My message 1"
    },
    {
        "message": "My other message 1"
    }
  ]
}

I want the resulting table:

description, message
"My description", "My other message"
"My description 1", "My other message 1"

I came to this question which is very close to what I want https://answers.splunk.com/answers/769708/how-to-access-a-property-on-the-last-element-in-an-1.html , but it doesn't work

For me, this would be:

| spath output=result path=param.response.tracking{}
| eval res = mvindex(result,mvcount(result)-1)
| table description, res.message

Any help is appreciated.

0 Karma

to4kawa
Ultra Champion
your search
| spath
| rename param.response.tracking{}.* as *
| table description message
| eval message=mvindex(message, -1)
0 Karma

anmolpatel
Builder

You're on the right track. For what you're after, you need the following:

source="Untitled-1.json" index="test" sourcetype="_json"
| spath output=message path=param.response.tracking{}.message
| eval res = mvindex(message, mvcount(message) - 1)
| stats values(res) as res by description

this will give:
description res
My description My other message
My description 1 My other message 1

The only err is res.message. The eval returns a single value when it executes the mvindex, so there is no nested value.

0 Karma

nordstromemg
New Member

This doesn't work for me

0 Karma

anmolpatel
Builder

I had modified the path, have reset it back to what you're using. Check again.

0 Karma

nordstromemg
New Member

Still not working, for what it's worth this

... | table param.result.tracking_details{}.message

returns
"My message"
"My other message"


"My message 1"
"My other message 1"

which is close, but I need the last item.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Cisco Data Fabric from Architecture to Investigation, Better SOC Visibility, and More ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...

The Trust Gap: Why a Data Foundation is Fundamental to an Agentic Enterprise

The Trust Gap: Why a data foundation is fundamental to an  Agentic Enterprise.   Agentic AI is transforming ...

Data Management Digest – September 2026

    Welcome to the September 2026 edition of Data Management Digest! September brought a fresh wave of ...