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!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...