Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Metrics UI] Correct inaccurate offsetting for non-rate aggregations inside of metrics threshold alerts #106947

Merged
merged 8 commits into from
Jul 28, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export const getElasticsearchMetricQuery = (
const to = timeframe.end;
const from = timeframe.start;

const deliveryDelay = 60 * 1000; // INFO: This allows us to account for any delay ES has in indexing the most recent data.

const aggregations =
aggType === Aggregators.COUNT
? {}
Expand Down Expand Up @@ -74,10 +76,12 @@ export const getElasticsearchMetricQuery = (
aggregatedIntervals: {
date_range: {
field: timefield,
ranges: Array.from(Array(Math.floor((to - from) / intervalAsMS)), (_, i) => ({
from: from + intervalAsMS * i,
to: from + intervalAsMS * (i + 1),
})),
ranges: [
{
from: from - intervalAsMS,
phillipb marked this conversation as resolved.
Show resolved Hide resolved
to: from + intervalAsMS - deliveryDelay,
},
],
},
aggregations,
},
Expand Down