Splunk Search

How do I get Cache Hit ratio?

spandana9
Engager

I have cache hit as well as cache miss reports, How do i get the ratio of cache hit i.e, cache hit / (cache hit + cache miss)?

0 Karma
1 Solution

jkat54
SplunkTrust
SplunkTrust

... | eval ratio=cacheHit/(cacheHit+cacheMiss) | ...

if cacheHit and cacheMiss arent fields... and specifically arent integers, then you'll have to create your own with some eval magic like this example which creates counters based on finding patterns in the raw event data:

... 
 | eval cacheHits=if(match(_raw,"Pattern that is found in cache hit events"),cacheHits+1,cacheHits) 
 | eval cacheMisses=if(match(_raw,"Pattern that is found in cache miss events"),cacheMisses+1,cacheMisses) 
 | eval cacheHitRatio=cacheHits/(cacheHits+cacheMisses)
 | table cacheHits, cacheMisses, cacheHitRatio

View solution in original post

jkat54
SplunkTrust
SplunkTrust

... | eval ratio=cacheHit/(cacheHit+cacheMiss) | ...

if cacheHit and cacheMiss arent fields... and specifically arent integers, then you'll have to create your own with some eval magic like this example which creates counters based on finding patterns in the raw event data:

... 
 | eval cacheHits=if(match(_raw,"Pattern that is found in cache hit events"),cacheHits+1,cacheHits) 
 | eval cacheMisses=if(match(_raw,"Pattern that is found in cache miss events"),cacheMisses+1,cacheMisses) 
 | eval cacheHitRatio=cacheHits/(cacheHits+cacheMisses)
 | table cacheHits, cacheMisses, cacheHitRatio

spandana9
Engager

Thank you.

0 Karma

jkat54
SplunkTrust
SplunkTrust

If this worked as an answer, please use the "mark as answer" link below the answer. The upvote is certainly appreciated as well. Glad to help!

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