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?
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