Getting Data In

Calculating math on three different searches

labaningombam
Explorer

Hi,

I need to write a query to find the time remaining to consume events.

 

index=x message.message="Response sent" message.feedId="v1" | stats count as Produced
index=y | spath RenderedMessage | search RenderedMessage="*/v1/xyz*StatusCode*2*"| stats count as Processed
index=z message.feedId="v1" | stats avg("message.durationMs") as AverageResponseTime

 

 

So I want to basically perform:
Average Time left = Produced - Processed /AverageResponseTime

How can I go about doing this?

Thank you so much

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

You could try something like this

index=x message.message="Response sent" message.feedId="v1" | stats count as Produced
| appendcols [ search index=y | spath RenderedMessage | search RenderedMessage="*/v1/xyz*StatusCode*2*"| stats count as Processed]
| appendcols [ search index=z message.feedId="v1" | stats avg("message.durationMs") as AverageResponseTime]
| eval AverageTimeLeft = (Produced - Processed) * AverageResponseTime

Note that I think your calculation should be a multiplication not a division

View solution in original post

labaningombam
Explorer

Thank you so much for the correction as well 🙂

This worked. 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You could try something like this

index=x message.message="Response sent" message.feedId="v1" | stats count as Produced
| appendcols [ search index=y | spath RenderedMessage | search RenderedMessage="*/v1/xyz*StatusCode*2*"| stats count as Processed]
| appendcols [ search index=z message.feedId="v1" | stats avg("message.durationMs") as AverageResponseTime]
| eval AverageTimeLeft = (Produced - Processed) * AverageResponseTime

Note that I think your calculation should be a multiplication not a division

Get Updates on the Splunk Community!

New Case Study Shows the Value of Partnering with Splunk Academic Alliance

The University of Nevada, Las Vegas (UNLV) is another premier research institution helping to shape the next ...

How to Monitor Google Kubernetes Engine (GKE)

We’ve looked at how to integrate Kubernetes environments with Splunk Observability Cloud, but what about ...

Index This | How can you make 45 using only 4?

October 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...