Splunk Search

I would like to show a field with no values on a certain time visible on a chart

Dark_Ichigo
Builder

I have the following search:

index=<index> operation=<operation> | transaction startswith="<>"=request endswith="<>"=response
maxevents=2 | eval interval=case(case(if(isnull(duration),5,duration<1),"0 - 1"), case(if(isnull(duration),5,duration<2),"1 - 2"),case(if(isnull(duration),5,duration<4),"2 - 4"),case(if(isnull(duration),5,duration<8),"4 - 8"),case(if(isnull(duration),5,duration<16),"8 - 16"),case(if(isnull(duration),5,duration<32),"16 - 32")) | bucket duration span=1 as seconds | stats count as nbr by interval| table interval nbr

The result only shows the intervals on the chart that have values and omits the others, what would be the best way to show the missing intervals that have no values on the chart?

0 Karma

Ayn
Legend

First of all, you seem to have misunderstood how to use case...either that, or you're using it in a weird way that you would have to explain. Is the idea to create a range from 0-1,1-2,2-4,4-8 etc, and have a default duration value of 5 if no duration value was found in the event? You could do this with fillnull, eval and case in a much simpler way:

... | fillnull duration value=5 | eval interval=case(duration<1,"0 - 1",duration<2,"1 - 2",duration<4,"2 - 4",duration<8,"4 - 8",duration<16,"8 - 16",duration<32,"16-32")

Or, I believe you could use rangemap:

... | fillnull duration value=5 | rangemap field=duration "1 - 2"=1-2 "2-4"=2-4 ... | rename range as interval

Either way, the reason intervals are omitted when there are no values is that there's no way for Splunk to know what missing intervals it's supposed to present. It's possible to work around this, have a look at nick's answer in this question: http://splunk-base.splunk.com/answers/47687/add-0-count?page=1&focusedAnswerId=47795#47795

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...