mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-16 09:42:29 -04:00
fix(metrics): align fleet series by time bucket, harden fleet page inputs
Address review findings on the fleet metrics page. Data correctness: - bucket raw Sentinel samples into epoch-aligned windows (5m/30m/2h per range) and average them, replacing per-server LTTB. Every server now reports the same bucket timestamps, so the fleet sums add up point by point instead of zigzagging between servers (and RX+TX really combine) - keep only the root mount in disk history, matching HasMetrics::getDiskMetrics - leave sparkline gaps as null instead of 0, so absent samples read as gaps Robustness: - normalize containerMetric in mount()/updatedContainerMetric(), so /metrics?cmetric=foo no longer throws an undefined array key - include the server uuid in the container row wire:key; system containers share one Sentinel id across servers - round the range start to the minute so the 60s history cache can hit - cap the Sentinel curl with --max-time 10, so one hung request cannot stall the serial per-server loop UI: - pass the spark time axis on first paint, so tooltips no longer show 1970 - show the active series name (RX/TX) in the server network chart tooltip
This commit is contained in:
@@ -131,6 +131,7 @@ $serverListboxOptions = array_merge(
|
||||
'id' => $chartId.'-spark-cpu',
|
||||
'initial' => $chartData['cpuSpark'] ?? [],
|
||||
'color' => '#3b82f6',
|
||||
'categories' => $chartData['sparkCategories'] ?? [],
|
||||
'event' => 'refreshChartData-'.$chartId,
|
||||
'key' => 'cpuSpark',
|
||||
'label' => $scoped ? 'CPU' : 'Fleet CPU',
|
||||
@@ -146,6 +147,7 @@ $serverListboxOptions = array_merge(
|
||||
'id' => $chartId.'-spark-memory',
|
||||
'initial' => $chartData['memSpark'] ?? [],
|
||||
'color' => '#8b5cf6',
|
||||
'categories' => $chartData['sparkCategories'] ?? [],
|
||||
'event' => 'refreshChartData-'.$chartId,
|
||||
'key' => 'memSpark',
|
||||
'label' => 'Memory used',
|
||||
@@ -161,6 +163,7 @@ $serverListboxOptions = array_merge(
|
||||
'id' => $chartId.'-spark-disk',
|
||||
'initial' => $chartData['diskSpark'] ?? [],
|
||||
'color' => '#ef4444',
|
||||
'categories' => $chartData['sparkCategories'] ?? [],
|
||||
'event' => 'refreshChartData-'.$chartId,
|
||||
'key' => 'diskSpark',
|
||||
'label' => $scoped ? 'Disk' : 'Fleet disk',
|
||||
@@ -176,6 +179,7 @@ $serverListboxOptions = array_merge(
|
||||
'id' => $chartId.'-spark-network',
|
||||
'initial' => $chartData['netSpark'] ?? [],
|
||||
'color' => '#10b981',
|
||||
'categories' => $chartData['sparkCategories'] ?? [],
|
||||
'event' => 'refreshChartData-'.$chartId,
|
||||
'key' => 'netSpark',
|
||||
'label' => 'Network',
|
||||
@@ -307,7 +311,7 @@ $serverListboxOptions = array_merge(
|
||||
default => round($c['cpu'] ?? 0).'%',
|
||||
};
|
||||
@endphp
|
||||
<div wire:key="fleet-container-{{ $c['id'] }}"
|
||||
<div wire:key="fleet-container-{{ $c['serverUuid'] ?? $c['server'] }}-{{ $c['id'] }}"
|
||||
class="data-table-row fleet-containers-table-grid border-b border-neutral-200 last:border-b-0 dark:border-white/[0.07]">
|
||||
<div class="self-center text-center text-[12px] tabular-nums text-neutral-400 dark:text-fg-faint">{{ $loop->iteration }}</div>
|
||||
<div class="flex min-w-0 flex-col">
|
||||
|
||||
@@ -209,7 +209,7 @@
|
||||
const timestamp = w.globals.seriesX[seriesIndex][dataPointIndex];
|
||||
|
||||
return `<div class="apexcharts-tooltip-custom">
|
||||
<div class="apexcharts-tooltip-custom-value">${name}: <span class="apexcharts-tooltip-value-bold">${formatter(value)}</span></div>
|
||||
<div class="apexcharts-tooltip-custom-value">${w.globals.seriesNames?.[seriesIndex] ?? name}: <span class="apexcharts-tooltip-value-bold">${formatter(value)}</span></div>
|
||||
<div class="apexcharts-tooltip-custom-title">Your time: ${formatLocalTimestamp(timestamp)}</div>
|
||||
<div class="apexcharts-tooltip-custom-title">UTC: ${formatUtcTimestamp(timestamp)}</div>
|
||||
</div>`;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
@param string $colorVar CSS custom property for the line color (e.g. --chart-status-3xx)
|
||||
@param ?string $event Livewire event to listen on for updates (optional)
|
||||
@param ?string $key payload key holding the numeric array (required with $event)
|
||||
@param ?array $categories initial x-axis timestamps (defaults to $series buckets)
|
||||
--}}
|
||||
@php
|
||||
$initial = $initial ?? [];
|
||||
@@ -23,7 +24,7 @@
|
||||
$color = $color ?? '';
|
||||
$event = $event ?? '';
|
||||
$key = $key ?? '';
|
||||
$initialCategories = array_column($series ?? [], 'bucket');
|
||||
$initialCategories = $categories ?? array_column($series ?? [], 'bucket');
|
||||
$label = $label ?? match ($key) {
|
||||
'requestsSpark' => 'Requests',
|
||||
'uniquesSpark' => 'Visitors',
|
||||
@@ -74,6 +75,7 @@
|
||||
timeZoneName: 'short',
|
||||
});
|
||||
const formatValue = value => {
|
||||
if (value === null || value === undefined) { return '—'; }
|
||||
const fmt = @js($format);
|
||||
if (fmt === 'bytes') {
|
||||
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
|
||||
Reference in New Issue
Block a user