Metrics validated.
This commit is contained in:
1 parent
f5aefb1f0b
commit
2141c3eacd
2 files changed
+316
-169
No files matched your search
@@ -343,17 +343,6 @@ class MonitorModule {
|
|||||||
|
|
||||||
const stats = hardwareStats[0];
|
const stats = hardwareStats[0];
|
||||||
|
|
||||||
if (stats?.net?.length) {
|
|
||||||
const elapsedSeconds = (new Date(dates.end).getTime() - new Date(dates.start).getTime()) / 1000;
|
|
||||||
stats.net = stats.net.map((iface) => ({
|
|
||||||
...iface,
|
|
||||||
bytesSentPerSec: iface.deltaBytesSent / elapsedSeconds,
|
|
||||||
bytesRecvPerSec: iface.deltaBytesRecv / elapsedSeconds,
|
|
||||||
packetsSentPerSec: iface.deltaPacketsSent / elapsedSeconds,
|
|
||||||
packetsRecvPerSec: iface.deltaPacketsRecv / elapsedSeconds,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...monitor.toObject(),
|
...monitor.toObject(),
|
||||||
stats,
|
stats,
|
||||||
|
|||||||
@@ -263,6 +263,9 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
|
|||||||
net: {
|
net: {
|
||||||
$push: "$net",
|
$push: "$net",
|
||||||
},
|
},
|
||||||
|
updatedAts: {
|
||||||
|
$push: "$updatedAt",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -378,9 +381,7 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
|
|||||||
},
|
},
|
||||||
net: {
|
net: {
|
||||||
$map: {
|
$map: {
|
||||||
input: {
|
input: { $range: [0, { $size: { $arrayElemAt: ["$net", 0] } }] },
|
||||||
$range: [0, { $size: { $arrayElemAt: ["$net", 0] } }],
|
|
||||||
},
|
|
||||||
as: "netIndex",
|
as: "netIndex",
|
||||||
in: {
|
in: {
|
||||||
name: {
|
name: {
|
||||||
@@ -395,211 +396,368 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
|
|||||||
"$$netIndex",
|
"$$netIndex",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
deltaBytesSent: {
|
bytesSentPerSecond: {
|
||||||
$subtract: [
|
$let: {
|
||||||
{
|
vars: {
|
||||||
$arrayElemAt: [
|
first: {
|
||||||
{
|
$arrayElemAt: [
|
||||||
$map: {
|
{ $map: { input: { $arrayElemAt: ["$net", 0] }, as: "iface", in: "$$iface.bytes_sent" } },
|
||||||
input: { $arrayElemAt: ["$net", { $subtract: [{ $size: "$net" }, 1] }] },
|
"$$netIndex",
|
||||||
as: "iface",
|
],
|
||||||
in: "$$iface.bytes_sent",
|
},
|
||||||
|
last: {
|
||||||
|
$arrayElemAt: [
|
||||||
|
{
|
||||||
|
$map: {
|
||||||
|
input: { $arrayElemAt: ["$net", { $subtract: [{ $size: "$net" }, 1] }] },
|
||||||
|
as: "iface",
|
||||||
|
in: "$$iface.bytes_sent",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
"$$netIndex",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
tFirst: { $arrayElemAt: ["$updatedAts", 0] },
|
||||||
|
tLast: { $arrayElemAt: ["$updatedAts", { $subtract: [{ $size: "$updatedAts" }, 1] }] },
|
||||||
|
},
|
||||||
|
in: {
|
||||||
|
$cond: [
|
||||||
|
{ $gt: [{ $subtract: ["$$tLast", "$$tFirst"] }, 0] },
|
||||||
|
{
|
||||||
|
$divide: [{ $subtract: ["$$last", "$$first"] }, { $divide: [{ $subtract: ["$$tLast", "$$tFirst"] }, 1000] }],
|
||||||
},
|
},
|
||||||
"$$netIndex",
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
},
|
||||||
$arrayElemAt: [
|
|
||||||
{ $map: { input: { $arrayElemAt: ["$net", 0] }, as: "iface", in: "$$iface.bytes_sent" } },
|
|
||||||
"$$netIndex",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
deltaBytesRecv: {
|
deltaBytesRecv: {
|
||||||
$subtract: [
|
$let: {
|
||||||
{
|
vars: {
|
||||||
$arrayElemAt: [
|
first: {
|
||||||
{
|
$arrayElemAt: [
|
||||||
$map: {
|
{ $map: { input: { $arrayElemAt: ["$net", 0] }, as: "iface", in: "$$iface.bytes_recv" } },
|
||||||
input: { $arrayElemAt: ["$net", { $subtract: [{ $size: "$net" }, 1] }] },
|
"$$netIndex",
|
||||||
as: "iface",
|
],
|
||||||
in: "$$iface.bytes_recv",
|
},
|
||||||
|
last: {
|
||||||
|
$arrayElemAt: [
|
||||||
|
{
|
||||||
|
$map: {
|
||||||
|
input: { $arrayElemAt: ["$net", { $subtract: [{ $size: "$net" }, 1] }] },
|
||||||
|
as: "iface",
|
||||||
|
in: "$$iface.bytes_recv",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
"$$netIndex",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
tFirst: { $arrayElemAt: ["$updatedAts", 0] },
|
||||||
|
tLast: { $arrayElemAt: ["$updatedAts", { $subtract: [{ $size: "$updatedAts" }, 1] }] },
|
||||||
|
},
|
||||||
|
in: {
|
||||||
|
$cond: [
|
||||||
|
{ $gt: [{ $subtract: ["$$tLast", "$$tFirst"] }, 0] },
|
||||||
|
{
|
||||||
|
$divide: [{ $subtract: ["$$last", "$$first"] }, { $divide: [{ $subtract: ["$$tLast", "$$tFirst"] }, 1000] }],
|
||||||
},
|
},
|
||||||
"$$netIndex",
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
},
|
||||||
$arrayElemAt: [
|
|
||||||
{ $map: { input: { $arrayElemAt: ["$net", 0] }, as: "iface", in: "$$iface.bytes_recv" } },
|
|
||||||
"$$netIndex",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
deltaPacketsSent: {
|
deltaPacketsSent: {
|
||||||
$subtract: [
|
$let: {
|
||||||
{
|
vars: {
|
||||||
$arrayElemAt: [
|
first: {
|
||||||
{
|
$arrayElemAt: [
|
||||||
$map: {
|
{ $map: { input: { $arrayElemAt: ["$net", 0] }, as: "iface", in: "$$iface.packets_sent" } },
|
||||||
input: { $arrayElemAt: ["$net", { $subtract: [{ $size: "$net" }, 1] }] },
|
"$$netIndex",
|
||||||
as: "iface",
|
],
|
||||||
in: "$$iface.packets_sent",
|
},
|
||||||
|
last: {
|
||||||
|
$arrayElemAt: [
|
||||||
|
{
|
||||||
|
$map: {
|
||||||
|
input: { $arrayElemAt: ["$net", { $subtract: [{ $size: "$net" }, 1] }] },
|
||||||
|
as: "iface",
|
||||||
|
in: "$$iface.packets_sent",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
"$$netIndex",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
tFirst: { $arrayElemAt: ["$updatedAts", 0] },
|
||||||
|
tLast: { $arrayElemAt: ["$updatedAts", { $subtract: [{ $size: "$updatedAts" }, 1] }] },
|
||||||
|
},
|
||||||
|
in: {
|
||||||
|
$cond: [
|
||||||
|
{ $gt: [{ $subtract: ["$$tLast", "$$tFirst"] }, 0] },
|
||||||
|
{
|
||||||
|
$divide: [{ $subtract: ["$$last", "$$first"] }, { $divide: [{ $subtract: ["$$tLast", "$$tFirst"] }, 1000] }],
|
||||||
},
|
},
|
||||||
"$$netIndex",
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
},
|
||||||
$arrayElemAt: [
|
|
||||||
{ $map: { input: { $arrayElemAt: ["$net", 0] }, as: "iface", in: "$$iface.packets_sent" } },
|
|
||||||
"$$netIndex",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
deltaPacketsRecv: {
|
deltaPacketsRecv: {
|
||||||
$subtract: [
|
$let: {
|
||||||
{
|
vars: {
|
||||||
$arrayElemAt: [
|
first: {
|
||||||
{
|
$arrayElemAt: [
|
||||||
$map: {
|
{
|
||||||
input: { $arrayElemAt: ["$net", { $subtract: [{ $size: "$net" }, 1] }] },
|
$map: {
|
||||||
as: "iface",
|
input: { $arrayElemAt: ["$net", 0] },
|
||||||
in: "$$iface.packets_recv",
|
as: "iface",
|
||||||
|
in: "$$iface.packets_recv",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
"$$netIndex",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
last: {
|
||||||
|
$arrayElemAt: [
|
||||||
|
{
|
||||||
|
$map: {
|
||||||
|
input: {
|
||||||
|
$arrayElemAt: [
|
||||||
|
"$net",
|
||||||
|
{
|
||||||
|
$subtract: [{ $size: "$net" }, 1],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
as: "iface",
|
||||||
|
in: "$$iface.packets_recv",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"$$netIndex",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
tFirst: { $arrayElemAt: ["$updatedAts", 0] },
|
||||||
|
tLast: {
|
||||||
|
$arrayElemAt: [
|
||||||
|
"$updatedAts",
|
||||||
|
{
|
||||||
|
$subtract: [{ $size: "$updatedAts" }, 1],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
in: {
|
||||||
|
$cond: [
|
||||||
|
{ $gt: [{ $subtract: ["$$tLast", "$$tFirst"] }, 0] },
|
||||||
|
{
|
||||||
|
$divide: [{ $subtract: ["$$last", "$$first"] }, { $divide: [{ $subtract: ["$$tLast", "$$tFirst"] }, 1000] }],
|
||||||
},
|
},
|
||||||
"$$netIndex",
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
},
|
||||||
$arrayElemAt: [
|
|
||||||
{ $map: { input: { $arrayElemAt: ["$net", 0] }, as: "iface", in: "$$iface.packets_recv" } },
|
|
||||||
"$$netIndex",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
deltaErrIn: {
|
deltaErrIn: {
|
||||||
$subtract: [
|
$let: {
|
||||||
{
|
vars: {
|
||||||
$arrayElemAt: [
|
first: {
|
||||||
{
|
$arrayElemAt: [{ $map: { input: { $arrayElemAt: ["$net", 0] }, as: "iface", in: "$$iface.err_in" } }, "$$netIndex"],
|
||||||
$map: {
|
},
|
||||||
input: { $arrayElemAt: ["$net", { $subtract: [{ $size: "$net" }, 1] }] },
|
last: {
|
||||||
as: "iface",
|
$arrayElemAt: [
|
||||||
in: "$$iface.err_in",
|
{
|
||||||
|
$map: {
|
||||||
|
input: { $arrayElemAt: ["$net", { $subtract: [{ $size: "$net" }, 1] }] },
|
||||||
|
as: "iface",
|
||||||
|
in: "$$iface.err_in",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
"$$netIndex",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
tFirst: { $arrayElemAt: ["$updatedAts", 0] },
|
||||||
|
tLast: { $arrayElemAt: ["$updatedAts", { $subtract: [{ $size: "$updatedAts" }, 1] }] },
|
||||||
|
},
|
||||||
|
in: {
|
||||||
|
$cond: [
|
||||||
|
{ $gt: [{ $subtract: ["$$tLast", "$$tFirst"] }, 0] },
|
||||||
|
{
|
||||||
|
$divide: [{ $subtract: ["$$last", "$$first"] }, { $divide: [{ $subtract: ["$$tLast", "$$tFirst"] }, 1000] }],
|
||||||
},
|
},
|
||||||
"$$netIndex",
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
},
|
||||||
$arrayElemAt: [{ $map: { input: { $arrayElemAt: ["$net", 0] }, as: "iface", in: "$$iface.err_in" } }, "$$netIndex"],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
deltaErrOut: {
|
deltaErrOut: {
|
||||||
$subtract: [
|
$let: {
|
||||||
{
|
vars: {
|
||||||
$arrayElemAt: [
|
first: {
|
||||||
{
|
$arrayElemAt: [
|
||||||
$map: {
|
{
|
||||||
input: { $arrayElemAt: ["$net", { $subtract: [{ $size: "$net" }, 1] }] },
|
$map: {
|
||||||
as: "iface",
|
input: { $arrayElemAt: ["$net", 0] },
|
||||||
in: "$$iface.err_out",
|
as: "iface",
|
||||||
|
in: "$$iface.err_out",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
"$$netIndex",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
last: {
|
||||||
|
$arrayElemAt: [
|
||||||
|
{
|
||||||
|
$map: {
|
||||||
|
input: {
|
||||||
|
$arrayElemAt: [
|
||||||
|
"$net",
|
||||||
|
{
|
||||||
|
$subtract: [{ $size: "$net" }, 1],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
as: "iface",
|
||||||
|
in: "$$iface.err_out",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"$$netIndex",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
tFirst: { $arrayElemAt: ["$updatedAts", 0] },
|
||||||
|
tLast: {
|
||||||
|
$arrayElemAt: [
|
||||||
|
"$updatedAts",
|
||||||
|
{
|
||||||
|
$subtract: [{ $size: "$updatedAts" }, 1],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
in: {
|
||||||
|
$cond: [
|
||||||
|
{ $gt: [{ $subtract: ["$$tLast", "$$tFirst"] }, 0] },
|
||||||
|
{
|
||||||
|
$divide: [{ $subtract: ["$$last", "$$first"] }, { $divide: [{ $subtract: ["$$tLast", "$$tFirst"] }, 1000] }],
|
||||||
},
|
},
|
||||||
"$$netIndex",
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
},
|
||||||
$arrayElemAt: [{ $map: { input: { $arrayElemAt: ["$net", 0] }, as: "iface", in: "$$iface.err_out" } }, "$$netIndex"],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
deltaDropIn: {
|
deltaDropIn: {
|
||||||
$subtract: [
|
$let: {
|
||||||
{
|
vars: {
|
||||||
$arrayElemAt: [
|
first: {
|
||||||
{
|
$arrayElemAt: [
|
||||||
$map: {
|
{
|
||||||
input: { $arrayElemAt: ["$net", { $subtract: [{ $size: "$net" }, 1] }] },
|
$map: {
|
||||||
as: "iface",
|
input: { $arrayElemAt: ["$net", 0] },
|
||||||
in: "$$iface.drop_in",
|
as: "iface",
|
||||||
|
in: "$$iface.drop_in",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
"$$netIndex",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
last: {
|
||||||
|
$arrayElemAt: [
|
||||||
|
{
|
||||||
|
$map: {
|
||||||
|
input: {
|
||||||
|
$arrayElemAt: [
|
||||||
|
"$net",
|
||||||
|
{
|
||||||
|
$subtract: [{ $size: "$net" }, 1],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
as: "iface",
|
||||||
|
in: "$$iface.drop_in",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"$$netIndex",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
tFirst: { $arrayElemAt: ["$updatedAts", 0] },
|
||||||
|
tLast: {
|
||||||
|
$arrayElemAt: [
|
||||||
|
"$updatedAts",
|
||||||
|
{
|
||||||
|
$subtract: [{ $size: "$updatedAts" }, 1],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
in: {
|
||||||
|
$cond: [
|
||||||
|
{ $gt: [{ $subtract: ["$$tLast", "$$tFirst"] }, 0] },
|
||||||
|
{
|
||||||
|
$divide: [{ $subtract: ["$$last", "$$first"] }, { $divide: [{ $subtract: ["$$tLast", "$$tFirst"] }, 1000] }],
|
||||||
},
|
},
|
||||||
"$$netIndex",
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
},
|
||||||
$arrayElemAt: [{ $map: { input: { $arrayElemAt: ["$net", 0] }, as: "iface", in: "$$iface.drop_in" } }, "$$netIndex"],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
deltaDropOut: {
|
deltaDropOut: {
|
||||||
$subtract: [
|
$let: {
|
||||||
{
|
vars: {
|
||||||
$arrayElemAt: [
|
first: {
|
||||||
{
|
$arrayElemAt: [
|
||||||
$map: {
|
{
|
||||||
input: { $arrayElemAt: ["$net", { $subtract: [{ $size: "$net" }, 1] }] },
|
$map: {
|
||||||
as: "iface",
|
input: { $arrayElemAt: ["$net", 0] },
|
||||||
in: "$$iface.drop_out",
|
as: "iface",
|
||||||
|
in: "$$iface.drop_out",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
"$$netIndex",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
last: {
|
||||||
|
$arrayElemAt: [
|
||||||
|
{
|
||||||
|
$map: {
|
||||||
|
input: {
|
||||||
|
$arrayElemAt: [
|
||||||
|
"$net",
|
||||||
|
{
|
||||||
|
$subtract: [{ $size: "$net" }, 1],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
as: "iface",
|
||||||
|
in: "$$iface.drop_out",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"$$netIndex",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
tFirst: { $arrayElemAt: ["$updatedAts", 0] },
|
||||||
|
tLast: {
|
||||||
|
$arrayElemAt: [
|
||||||
|
"$updatedAts",
|
||||||
|
{
|
||||||
|
$subtract: [{ $size: "$updatedAts" }, 1],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
in: {
|
||||||
|
$cond: [
|
||||||
|
{ $gt: [{ $subtract: ["$$tLast", "$$tFirst"] }, 0] },
|
||||||
|
{
|
||||||
|
$divide: [{ $subtract: ["$$last", "$$first"] }, { $divide: [{ $subtract: ["$$tLast", "$$tFirst"] }, 1000] }],
|
||||||
},
|
},
|
||||||
"$$netIndex",
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
},
|
||||||
$arrayElemAt: [{ $map: { input: { $arrayElemAt: ["$net", 0] }, as: "iface", in: "$$iface.drop_out" } }, "$$netIndex"],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
deltaFifoIn: {
|
|
||||||
$subtract: [
|
|
||||||
{
|
|
||||||
$arrayElemAt: [
|
|
||||||
{
|
|
||||||
$map: {
|
|
||||||
input: { $arrayElemAt: ["$net", { $subtract: [{ $size: "$net" }, 1] }] },
|
|
||||||
as: "iface",
|
|
||||||
in: "$$iface.fifo_in",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"$$netIndex",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$arrayElemAt: [{ $map: { input: { $arrayElemAt: ["$net", 0] }, as: "iface", in: "$$iface.fifo_in" } }, "$$netIndex"],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
deltaFifoOut: {
|
|
||||||
$subtract: [
|
|
||||||
{
|
|
||||||
$arrayElemAt: [
|
|
||||||
{
|
|
||||||
$map: {
|
|
||||||
input: { $arrayElemAt: ["$net", { $subtract: [{ $size: "$net" }, 1] }] },
|
|
||||||
as: "iface",
|
|
||||||
in: "$$iface.fifo_out",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"$$netIndex",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$arrayElemAt: [{ $map: { input: { $arrayElemAt: ["$net", 0] }, as: "iface", in: "$$iface.fifo_out" } }, "$$netIndex"],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
firstUpdatedAt: 1,
|
||||||
|
lastUpdatedAt: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in new issue
Block a user