Compute infrastructure metrics
cgen-98433ae800254a888283eefc5d47b267
This commit is contained in:
parent
9099b72a41
commit
5bb38b9e38
1 changed files with 42 additions and 0 deletions
|
|
@ -369,6 +369,48 @@ export default function Admin() {
|
||||||
);
|
);
|
||||||
}).length;
|
}).length;
|
||||||
|
|
||||||
|
const infrastructureMetrics = useMemo(() => {
|
||||||
|
if (!statusSnapshot.length) {
|
||||||
|
return {
|
||||||
|
averageResponseTime: null as number | null,
|
||||||
|
averageUptime: null as number | null,
|
||||||
|
degradedServices: 0,
|
||||||
|
healthyServices: 0,
|
||||||
|
totalServices: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const totalServices = statusSnapshot.length;
|
||||||
|
const degradedServices = statusSnapshot.filter(
|
||||||
|
(service) => service.status !== "operational",
|
||||||
|
).length;
|
||||||
|
const averageResponseTime = Math.round(
|
||||||
|
statusSnapshot.reduce((sum, service) => sum + service.responseTime, 0) /
|
||||||
|
totalServices,
|
||||||
|
);
|
||||||
|
const uptimeAccumulator = statusSnapshot.reduce(
|
||||||
|
(acc, service) => {
|
||||||
|
const numeric = Number.parseFloat(service.uptime);
|
||||||
|
if (Number.isFinite(numeric)) {
|
||||||
|
return { total: acc.total + numeric, count: acc.count + 1 };
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
},
|
||||||
|
{ total: 0, count: 0 },
|
||||||
|
);
|
||||||
|
const averageUptime = uptimeAccumulator.count
|
||||||
|
? uptimeAccumulator.total / uptimeAccumulator.count
|
||||||
|
: null;
|
||||||
|
|
||||||
|
return {
|
||||||
|
averageResponseTime,
|
||||||
|
averageUptime,
|
||||||
|
degradedServices,
|
||||||
|
healthyServices: totalServices - degradedServices,
|
||||||
|
totalServices,
|
||||||
|
};
|
||||||
|
}, [statusSnapshot]);
|
||||||
|
|
||||||
const overviewStats = useMemo(
|
const overviewStats = useMemo(
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue