Splunk Search

Calculate Ratio of Two Counter Streams

sks
New Member

I've two counter streams, I would like to display that as a percentage as

B/(B+C)  in the chart but it always gives me an error. 

B = data('prod.metrics.biz.l2_cache_miss', rollup='rate', extrapolation='zero').publish(label='B')
C = data('prod.metrics.biz.l2_cache_hit', rollup='rate', extrapolation='zero').publish(label='C')


How can I create a new metrics out of these two to find either cache hit or miss percentage? 

Labels (2)
0 Karma

KendallW
Contributor

Hi @sks if you want just the percentage of misses and the percentage of hits, you can do this with eval:

| eval Bperc=('B'/(B+C))*100
| eval Cperc=('C'/(B+C))*100

If you want to show this in a chart (e.g. pie chart) you don't need to calculate the percentage as Splunk will do this for you, but you will need to get the values of B and C in the same column using transpose. Example:

KendallW_0-1711418990776.png

 

0 Karma

sks
New Member

Hi @KendallW  

Thanks for the reply, but that does not work as I'm plotting this in the line chart.   The data is coming to SignalFx from the StatsD agent.   

Screenshot 2024-03-26 at 11.24.54 AM.png

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!

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...