Splunk Cloud Platform

Dynamically adjust percentage based on time for 5 min intervals

msrama5
Explorer

Hello, I have this query that needs dynamically adjusted for time duration, the results are written every 5 mins so , in 24 hrs period there will be 288 results written,  I am dividing by 288 in query below to calculate percentage rate.

earliest = -24h index=error_log  | eventstats count as fcount by "Properties.QueryName" |
eval percent = round((fcount/288)*100,2) | stats values(percent) as Failure_Percentage by "Properties.QueryName" 

If I change this query to pass start time and end time , the query needs to calculate duration and divide by 5 mins to get number of data counts and calculate the percentage rate, how can this query be modified to calculate time duration and find the right count to divide assuming data is expected every 5 mins.

 

Labels (1)
0 Karma

thambisetty
SplunkTrust
SplunkTrust
earliest = -24h index=error_log 
| stats count as fcount by "Properties.QueryName" 
| addinfo 
| fields - info_sid,info_search_time 
| eval slices=((info_max_time-info_min_time)/60)/5
| eval percent = round((fcount/slices)*100,2) 
| stats values(percent) as Failure_Percentage by "Properties.QueryName" 
————————————
If this helps, give a like below.
0 Karma

Nisha18789
Builder

Hi @msrama5 , could you please elaborate more on what you are trying to achieve in this query.

Also, can you check if this gives you the expected result?

earliest = -24h index=error_log  | top  "Properties.QueryName" 

 

0 Karma
Get Updates on the Splunk Community!

Upcoming Webinar: Unmasking Insider Threats with Slunk Enterprise Security’s UEBA

Join us on Wed, Dec 10. at 10AM PST / 1PM EST for a live webinar and demo with Splunk experts! Discover how ...

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...