Splunk Search

How to count the size of json array of a single event

wood1986
Explorer

How to count the size of json array of a single event

For example {"a" : [{"b": true}, {"b": true}, {"c": true}]}

name   size
===========
a      3
Tags (3)
1 Solution

alacercogitatus
SplunkTrust
SplunkTrust

You can use the spath command.

your_search | spath path=a{} output=name | stats count(name) as name

http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath

View solution in original post

0 Karma

alacercogitatus
SplunkTrust
SplunkTrust

You can use the spath command.

your_search | spath path=a{} output=name | stats count(name) as name

http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath

0 Karma

alacercogitatus
SplunkTrust
SplunkTrust

your_search | spath path=a{} output=aName | spath path=z{} output=zName | stats count(aName) as a count(zName) as z by id

0 Karma

wood1986
Explorer

my example is too simple. for a single event
{"id": 32413
"a" : [{"b": true}, {"b": true}, {"c": true}].
"z" : [{"a": 1}, {"d":2}]}

I want this output

id    a    z
=============
32413  3    2
0 Karma
Get Updates on the Splunk Community!

Splunk App for Anomaly Detection End of Life Announcment

Q: What is happening to the Splunk App for Anomaly Detection?A: Splunk is officially announcing the ...

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...