Splunk Search

How to display zero for latest(values)

varsh_6_8_6
Explorer

The following is my query.


index="xyz"  host="*" 
|fields host,messagevalue
| search "total payment count :"
|eval messagevalue=mvindex(split(messagevalue,":"),1)
|stats latest(messagevalue)

For a given period if there are no events, No results found is displayed. Instead I want zeo to be displayed.

I tried using fillnull but no luck.

Labels (1)
Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| appendpipe [| stats count | where count==0]
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @varsh_6_8_6 ,

you can find many anwers to this question and I proposed it in Splunk ideas to have this feature in fashboards and it's a future prospect, if you think that's interesting, upvote for it at https://ideas.splunk.com/ideas/EID-I-572 

Anyway, in the meantime, only one question before the answer: is messageValue a number or what else?

if it's a number, please try:

index="xyz"  host="*" "total payment count :"
| eval messagevalue=mvindex(split(messagevalue,":"),1)
| stats latest(messagevalue) AS messagevalue
| append [ | makeresults | eval messagevalue=0 | fields messagevalue ]
| stats sum(messagevalue) AS messagevalue

Ciao.

Giuseppe

0 Karma

varsh_6_8_6
Explorer

Hi @gcusello 
Thank you for the inputs. I have voted for the idea which is essential.
Also I have both number and string.
The one mentioned worked perfectly for the number. 
Is there any way to display "No files found" in case there no latest events in a particular time.
Regards,
Varsh

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @varsh_6_8_6 ,

in this case, please try

index="xyz"  host="*" "total payment count :"
| eval messagevalue=mvindex(split(messagevalue,":"),1)
| appendpipe [ stats count | eval messagevalue="No File Found" | where count==0 | fields - count ]

Ciao.

Giuseppe

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

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...