mirror of
https://github.com/hyperdxio/hyperdx
synced 2026-04-21 13:37:15 +00:00
Metric Chart Alerts: increase duration for at least 2 data points (#147)
This commit is contained in:
parent
29d1e03071
commit
bb4f90d26b
3 changed files with 16 additions and 2 deletions
5
.changeset/shaggy-peas-shop.md
Normal file
5
.changeset/shaggy-peas-shop.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@hyperdx/api': patch
|
||||
---
|
||||
|
||||
Adjust time window for sum-rate alerts
|
||||
|
|
@ -689,7 +689,7 @@ const getMetricsTagsCached = async (teamId: string) => {
|
|||
}
|
||||
};
|
||||
|
||||
const isRateAggFn = (aggFn: AggFn) => {
|
||||
export const isRateAggFn = (aggFn: AggFn) => {
|
||||
return (
|
||||
aggFn === AggFn.SumRate ||
|
||||
aggFn === AggFn.AvgRate ||
|
||||
|
|
|
|||
|
|
@ -421,12 +421,21 @@ export const processAlert = async (now: Date, alert: AlertDocument) => {
|
|||
series.field
|
||||
) {
|
||||
targetDashboard = dashboard;
|
||||
const startTimeMs = fns.getTime(checkStartTime);
|
||||
let startTimeMs = fns.getTime(checkStartTime);
|
||||
const endTimeMs = fns.getTime(checkEndTime);
|
||||
const [metricName, rawMetricDataType] = series.field.split(' - ');
|
||||
const metricDataType = z
|
||||
.nativeEnum(clickhouse.MetricsDataType)
|
||||
.parse(rawMetricDataType);
|
||||
if (
|
||||
metricDataType === clickhouse.MetricsDataType.Sum &&
|
||||
clickhouse.isRateAggFn(series.aggFn)
|
||||
) {
|
||||
// adjust the time so that we have enough data points to calculate a rate
|
||||
startTimeMs = fns
|
||||
.subMinutes(startTimeMs, windowSizeInMins)
|
||||
.getTime();
|
||||
}
|
||||
checksData = await clickhouse.getMetricsChart({
|
||||
aggFn: series.aggFn,
|
||||
dataType: metricDataType,
|
||||
|
|
|
|||
Loading…
Reference in a new issue