Exclude degraded-egress checks from every aggregate
A degraded episode now reads as a gap in monitoring rather than as downtime
or as a dip in response time. The exclusion is applied once per query, in the
top-level $match, so no pipeline can count a degraded check by omission.
- check.query.ts: EXCLUDE_DEGRADED_EGRESS_MATCH is the only helper;
IS_NOT_DEGRADED_EGRESS_EXPR and the $cond accumulators it fed are gone.
- findUptimeDateRangeChecks: excludes at the match, so the response-time
series, the up/down series and the averages drop degraded checks too.
- findPageSpeedDateRangeChecks: excludes as well; pagespeed is egress
attributable and was previously missed.
- getDailyStatusBuckets: excludes at the match; the group shapes and the
totalChecks > 0 guard revert to their original form.
- check.docker.aggregation.ts, check.hardware.aggregations.ts: reverted.
Neither type is egress attributable, so their checks never carry the flag
and the filters were dead code. A test now pins that decision.
- Tests: the gap behaviour, a window that was entirely degraded, pagespeed,
the team listing and the resolve filter, and an incident that stays open
when egress drops during it.
🔧
This commit is contained in:
1 parent
4335e6b7b6
commit
d865103fb5
7 files changed
+99
-66
No files matched your search
@@ -1,6 +1,5 @@
|
||||
import CheckModel from "@/domain/checks/check.model.js";
|
||||
import { DockerContainerStatsBucket, DockerStatsBucket } from "@/domain/checks/check.type.js";
|
||||
import { EXCLUDE_DEGRADED_EGRESS_MATCH, IS_NOT_DEGRADED_EGRESS_EXPR } from "@/domain/checks/check.query.js";
|
||||
import mongoose from "mongoose";
|
||||
|
||||
type DateRange = { start: Date; end: Date };
|
||||
@@ -10,7 +9,6 @@ export const getDockerTotalChecks = async (monitorId: string, dates: DateRange):
|
||||
"metadata.monitorId": new mongoose.Types.ObjectId(monitorId),
|
||||
"metadata.type": "docker",
|
||||
createdAt: { $gte: dates.start, $lte: dates.end },
|
||||
...EXCLUDE_DEGRADED_EGRESS_MATCH,
|
||||
});
|
||||
|
||||
export const getDockerUpChecks = async (monitorId: string, dates: DateRange): Promise<{ totalChecks: number }> => {
|
||||
@@ -36,9 +34,8 @@ export const getDockerStats = async (monitorId: string, dates: DateRange, dateSt
|
||||
$group: {
|
||||
_id: { $dateToString: { format: dateString, date: "$createdAt" } },
|
||||
avgResponseTime: { $avg: "$responseTime" },
|
||||
// Counts exclude degraded-egress checks like aggregateData.totalChecks does; the response-time average keeps them.
|
||||
upCount: { $sum: { $cond: [{ $and: [{ $eq: ["$status", true] }, IS_NOT_DEGRADED_EGRESS_EXPR] }, 1, 0] } },
|
||||
totalCount: { $sum: { $cond: [IS_NOT_DEGRADED_EGRESS_EXPR, 1, 0] } },
|
||||
upCount: { $sum: { $cond: [{ $eq: ["$status", true] }, 1, 0] } },
|
||||
totalCount: { $sum: 1 },
|
||||
avgRunning: { $avg: "$containerSummary.running" },
|
||||
avgTotal: { $avg: "$containerSummary.total" },
|
||||
avgUnhealthy: { $avg: "$containerSummary.unhealthy" },
|
||||
|
||||
Reference in new issue
Block a user