I have a query similar to the one below.
index = "idx" source = "mysource" |spath path=myField output=res|stats count by res
| where res="xyz"
Is there a way to get the search to return zero if no rows are returned? The reason Im asking for this is because this is the query Im using to populate values into a dashboard panel. If no rows are returned I would prefer the panel show zero instead of no results.
There might be a more graceful way someone will provide, but I generally add something like this to the end, forcing a row with a 0 value, and then doing another quick sum before displaying it.
| append
[makeresults |eval count=0]
|stats sum(count) as count
This is another way to get count=0
| appendpipe
[stats count
| where count=0
| eval res="xyz"]
Having said that, there may be a better way depending on your full search.
Thank you! I will give this a try!
There might be a more graceful way someone will provide, but I generally add something like this to the end, forcing a row with a 0 value, and then doing another quick sum before displaying it.
| append
[makeresults |eval count=0]
|stats sum(count) as count