Splunk Search

How to filter out those with empty JSON field?

sanggonlee
New Member

My logs have a JSON field, like this:

{
  "foo": 5,
  "bar": {}
}

I'd like to filter out logs that have an empty JSON for the "bar" field, like in the above example.

How do I do that? I tried something like 

where len('bar{}') > 0

but didn't work.

Thank you so much

Labels (1)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

Note bar is not an array, therefore bar{} does not exist.  In that sample data, bar is null.  So, to exclude them,

 

| where isnotnull(bar)

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try this.

| where isnotnull("bar.*")
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Leveraging Detections from the Splunk Threat Research Team & Cisco Talos

  Now On Demand  Stay ahead of today’s evolving threats with the combined power of the Splunk Threat Research ...

New in Splunk Observability Cloud: Automated Archiving for Unused Metrics

Automated Archival is a new capability within Metrics Management; which is a robust usage & cost optimization ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...