Splunk Search

Adding Empty JSON Array Count To Chart

samkass
New Member

Below, I have a chart being created which is supposed to show how many times we see each tag we find in a "tags" array in JSON with spath, and chart the names of the tags alongside the count for that tag. However, I'd also like an entry in the chart that displays a count of all the hits that had no tags.

(my query) | spath input=_raw output=tags path=tags{} | chart count over tags

I found several "splunk>answers" questions with a solution to counting array size, and can even, using a slightly different query, chart the tag count for each record. But I can't figure out how to:
1. count the empty tags in a way that assigns it to some variable, and
2. chart that variable with a "NONE" title alongsize all the other tag counts

Tags (4)
0 Karma

DalJeanis
Legend

Do this after your spath and before chart.

| eval tags=coalesce(tags,"NONE")
0 Karma

DalJeanis
Legend

Can you post a non-confidential sample event?

0 Karma
Get Updates on the Splunk Community!

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 ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...