Splunk Search

Find time difference between two events with different search conditions and same keys, compile all difference by keys?

roshankandeIntu
Loves-to-Learn Lots

Hey splunk community!

I need to create a search query to find instances where the time between a "Cache set' log from my application and a "Cache miss" log is not equal to a certain value(The configured TTL), for any cache key.

I've attempted starting with a particular key(sampleKey) but the end goal is to tabularize these results for all keys.

Here's my attempt to calculate the time difference for a sampleKey, between the set and miss times :

index= authzds-e2e* "setting value into memcached" "key=sampleKey" [search index=authzds-e2e* "Cache status=miss" "key=sampleKey" | stats latest(_time) as missTime ] | stats earliest(_time) as setTime| eval timeDiff=setTime-missTime




My goal is to calculate the difference between consecutive set and miss events, key-wise (not earliest/latest as in the above query)

Labels (5)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

You can use transaction.

index= authzds-e2e* ("setting value into memcached" OR "Cache status=miss")
| transaction key startswith="Cache status=miss" endswith="setting value into memcached"
| stats avg(duration) by key

 Of course, transaction is expensive.  So use stats 

Tags (1)
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!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...