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!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...