Splunk Search

Timechart: How to show "0"when no results found

kryzew
Explorer

Hello,

I'm try go get "0" in my result when there is no events. I get only "no result found".

index=*mysearch
| timechart count as count
| accum count as count


Any idea?


Labels (1)
0 Karma
1 Solution

rafamss
Contributor
0 Karma

kryzew
Explorer

First solution work for me fine, thank you both for your help.

BR

0 Karma

rafamss
Contributor

Hey,

Did you see this topic: https://community.splunk.com/t5/Splunk-Search/Timecharts-and-how-to-avoid-quot-no-results-found-insp...
They resolved the same problem that you are facing.

0 Karma

tonyread
Observer
| makeresults 1 
| timechart count span=1m 
| eval flag=1 
| append 
    [ search index=doesnotexist 
    | timechart count span=1m] 
| timechart sum(eval(flag!=1)) as count 
| fillnull count

 

Not the most elegant but this might do what you're looking for.  Use the makeresults command to force a single result, which you can then do a timecount on, and append that with your actual search (index=*mysearch).  If that now returns 0 results, the first search forces in its results and avoids the "no results found" message.  I've asumed you want span=1m.  You can experiment with this.

Of course, if you just want a single zero as your result, not a table of zeros as in my solution, then that requires a different approach.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...