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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...