修复BUG
This commit is contained in:
@@ -172,7 +172,8 @@ async function getOverviewMetrics(url, sourceName) {
|
||||
// Total traffic transmitted in last 24h
|
||||
query(url, 'sum by (instance, job) (increase(node_network_transmit_bytes_total{device!~"lo|veth.*|docker.*|br-.*"}[24h]))').catch(() => []),
|
||||
// Up instances (at least one successful scrape in last 5m)
|
||||
query(url, 'max_over_time(up{job=~".*node.*|.*exporter.*"}[5m])').catch(() => [])
|
||||
// We broaden the job filter to catch more variations of node-exporter jobs
|
||||
query(url, 'max_over_time(up{job=~".*node.*|.*exporter.*|.*host.*"}[5m])').catch(() => [])
|
||||
]);
|
||||
|
||||
// Build per-instance data map
|
||||
@@ -252,6 +253,14 @@ async function getOverviewMetrics(url, sourceName) {
|
||||
inst.netTx = parseFloat(r.value[1]) || 0;
|
||||
}
|
||||
|
||||
// Final check: If an instance has non-zero CPU or Memory total data but is marked offline,
|
||||
// it means we missed its 'up' metric due to job labels, but it's clearly sending data.
|
||||
for (const inst of instances.values()) {
|
||||
if (!inst.up && (inst.cpuPercent > 0 || inst.memTotal > 0)) {
|
||||
inst.up = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Aggregate
|
||||
let totalCpuUsed = 0, totalCpuCores = 0;
|
||||
let totalMemUsed = 0, totalMemTotal = 0;
|
||||
@@ -408,7 +417,7 @@ function mergeCpuHistories(histories) {
|
||||
async function getTrafficHistoryRange(url) {
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
const start = now - 86400; // 24h ago
|
||||
const step = 300; // 5 minutes
|
||||
const step = 5; // 5 seconds (17,280 points for 24h)
|
||||
|
||||
const queries = [
|
||||
'sum(node_network_receive_bytes_total{device!~"lo|veth.*|docker.*|br-.*"})',
|
||||
|
||||
Reference in New Issue
Block a user