fix(metrics): find the Coolify data disk in Sentinel 1.1.3 disk metrics

Closes #12315
This commit is contained in:
Andras Bacsai
2026-10-25 23:48:21 +01:00
parent 80ce0efe7e
commit e7ecc0e1f9
3 changed files with 47 additions and 10 deletions
+5 -4
View File
@@ -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<int, array<string, mixed>> $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));
}
/**
@@ -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 }]);
@@ -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]]);
});