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!

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

(view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...