From e7ecc0e1f900abf0aea932877e2b1616d94f9f5a Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Sun, 25 Oct 2026 23:48:17 +0100 Subject: [PATCH] fix(metrics): find the Coolify data disk in Sentinel 1.1.3 disk metrics Closes #12315 --- app/Services/SentinelMetricsClient.php | 9 ++++--- .../views/livewire/server/charts.blade.php | 21 ++++++++++----- .../Services/SentinelMetricsClientTest.php | 27 +++++++++++++++++++ 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/app/Services/SentinelMetricsClient.php b/app/Services/SentinelMetricsClient.php index 6980861e6e..b9ad06a164 100644 --- a/app/Services/SentinelMetricsClient.php +++ b/app/Services/SentinelMetricsClient.php @@ -165,9 +165,10 @@ class SentinelMetricsClient } /** - * The mount that stands for the root disk: `/`, else Sentinel's data bind mount. - * Sentinel 1.1.2 and older run in a container and report only their own mounts, - * so the host disk that holds /data/coolify is reported as `/app/db`. + * The mount that stands for the root disk: `/`, else the disk that holds /data/coolify. + * Sentinel runs in a container and reports only the disks of its own mounts: + * 1.1.2 and older as `/app/db`, 1.1.3 and newer by host mount point, which is + * `/data` or `/data/coolify` when that directory is on its own disk. * * @param array> $rows */ @@ -175,7 +176,7 @@ class SentinelMetricsClient { $mounts = array_column($rows, 'mount'); - return collect(['/', '/app/db'])->first(fn ($mount) => in_array($mount, $mounts, true)); + return collect(['/', '/app/db', '/data/coolify', '/data'])->first(fn ($mount) => in_array($mount, $mounts, true)); } /** diff --git a/resources/views/livewire/server/charts.blade.php b/resources/views/livewire/server/charts.blade.php index d626c883f9..43eb732701 100644 --- a/resources/views/livewire/server/charts.blade.php +++ b/resources/views/livewire/server/charts.blade.php @@ -334,12 +334,21 @@ }, }, }); - diskChart.updateSeries([{ name: 'Disk', data: data.diskSeries || [] }]); - networkChart.updateSeries([ - { name: 'RX', data: data.networkRxSeries || [] }, - { name: 'TX', data: data.networkTxSeries || [] }, - ]); - loadChart.updateSeries([{ name: 'Load', data: data.loadSeries || [] }]); + diskChart.updateOptions({ + series: [{ name: 'Disk', data: data.diskSeries || [] }], + noData: { text: 'No disk metrics available' }, + }); + networkChart.updateOptions({ + series: [ + { name: 'RX', data: data.networkRxSeries || [] }, + { name: 'TX', data: data.networkTxSeries || [] }, + ], + noData: { text: 'No network metrics available' }, + }); + loadChart.updateOptions({ + series: [{ name: 'Load', data: data.loadSeries || [] }], + noData: { text: 'No load metrics available' }, + }); renderLegend('cpu', [{ name: 'CPU', color: cpuColor, data: data.cpuSeries, formatter: formatPercent }]); renderLegend('memory', [{ name: 'Memory', color: ramColor, data: data.memorySeries, formatter: formatPercent }]); diff --git a/tests/Unit/Services/SentinelMetricsClientTest.php b/tests/Unit/Services/SentinelMetricsClientTest.php index 6f705c0da0..4bf1793d4c 100644 --- a/tests/Unit/Services/SentinelMetricsClientTest.php +++ b/tests/Unit/Services/SentinelMetricsClientTest.php @@ -220,3 +220,30 @@ it('prefers the root mount over the Sentinel data mount', function () { expect($client->history('disk', '24h'))->toBe([[1699999800000, 60.0]]); }); + +it('uses the host mount of the Coolify data directory when it is on its own disk', function (string $dataMount) { + $client = fakeMetricsClient(); + $client->bodies = [ + '/summary' => json_encode(['disk' => [ + ['mount' => $dataMount, 'used' => 20, 'total' => 100, 'usedPercent' => 20], + ['mount' => '/boot', 'used' => 90, 'total' => 100, 'usedPercent' => 90], + ]]), + '/disk/history' => json_encode([ + ['time' => 1700000000000, 'mount' => $dataMount, 'usedPercent' => 20], + ['time' => 1700000000000, 'mount' => '/boot', 'usedPercent' => 90], + ]), + ]; + + expect($client->summary()['diskPercent'])->toBe(20.0) + ->and($client->history('disk', '24h'))->toBe([[1699999800000, 20.0]]); +})->with(['/data', '/data/coolify']); + +it('prefers the root mount over the host mount of the Coolify data directory', function () { + $client = fakeMetricsClient(); + $client->bodies = ['/disk/history' => json_encode([ + ['time' => 1700000000000, 'mount' => '/data', 'usedPercent' => 20], + ['time' => 1700000000000, 'mount' => '/', 'usedPercent' => 60], + ])]; + + expect($client->history('disk', '24h'))->toBe([[1699999800000, 60.0]]); +});