fix(monitoring): hostname, tooltip timestamps, default range (v0.5.1)

- Bug 1: Read hostname from /host/etc/hostname instead of os.Hostname()
  which returns the container ID inside Docker. Added volume mount.
- Bug 2: Tooltip callback used parsed.x (category index) instead of
  label (actual timestamp), showing 1970 dates.
- Bug 3+4: Default range changed from 24h to 1h so charts show data
  immediately on new deployments with limited history.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-16 11:01:08 +01:00
parent b43ccf698a
commit b19682a767
3 changed files with 15 additions and 9 deletions
+2
View File
@@ -27,6 +27,8 @@ services:
- /sys:/host/sys:ro - /sys:/host/sys:ro
# Host OS info — for monitoring page system info # Host OS info — for monitoring page system info
- /etc/os-release:/host/etc/os-release:ro - /etc/os-release:/host/etc/os-release:ro
# Host hostname — for monitoring page (os.Hostname() returns container ID)
- /etc/hostname:/host/etc/hostname:ro
environment: environment:
- TZ=Europe/Budapest - TZ=Europe/Budapest
labels: labels:
+5 -1
View File
@@ -16,8 +16,12 @@ import (
func GetStaticInfo() StaticSystemInfo { func GetStaticInfo() StaticSystemInfo {
info := StaticSystemInfo{} info := StaticSystemInfo{}
// Hostname // Hostname — try host mount first, fall back to os.Hostname()
if data, err := os.ReadFile("/host/etc/hostname"); err == nil {
info.Hostname = strings.TrimSpace(string(data))
} else {
info.Hostname, _ = os.Hostname() info.Hostname, _ = os.Hostname()
}
// OS — try host mount first, fall back to container's // OS — try host mount first, fall back to container's
info.OS = readOSRelease("/host/etc/os-release") info.OS = readOSRelease("/host/etc/os-release")
@@ -41,9 +41,9 @@
<div class="monitor-card-header"> <div class="monitor-card-header">
<h3>Rendszer metrikák</h3> <h3>Rendszer metrikák</h3>
<div class="time-range-bar" id="system-range-bar"> <div class="time-range-bar" id="system-range-bar">
<button class="filter-btn" data-range="1h">1 óra</button> <button class="filter-btn active" data-range="1h">1 óra</button>
<button class="filter-btn" data-range="6h">6 óra</button> <button class="filter-btn" data-range="6h">6 óra</button>
<button class="filter-btn active" data-range="24h">24 óra</button> <button class="filter-btn" data-range="24h">24 óra</button>
<button class="filter-btn" data-range="7d">7 nap</button> <button class="filter-btn" data-range="7d">7 nap</button>
<button class="filter-btn" data-range="30d">30 nap</button> <button class="filter-btn" data-range="30d">30 nap</button>
</div> </div>
@@ -94,9 +94,9 @@
<div class="monitor-card-header"> <div class="monitor-card-header">
<h3 id="container-detail-title"></h3> <h3 id="container-detail-title"></h3>
<div class="time-range-bar" id="container-range-bar"> <div class="time-range-bar" id="container-range-bar">
<button class="filter-btn" data-range="1h">1 óra</button> <button class="filter-btn active" data-range="1h">1 óra</button>
<button class="filter-btn" data-range="6h">6 óra</button> <button class="filter-btn" data-range="6h">6 óra</button>
<button class="filter-btn active" data-range="24h">24 óra</button> <button class="filter-btn" data-range="24h">24 óra</button>
<button class="filter-btn" data-range="7d">7 nap</button> <button class="filter-btn" data-range="7d">7 nap</button>
</div> </div>
<button class="btn btn-outline btn-sm" onclick="closeContainerDetail()">Bezárás</button> <button class="btn btn-outline btn-sm" onclick="closeContainerDetail()">Bezárás</button>
@@ -168,7 +168,7 @@
callbacks: { callbacks: {
title: function(items) { title: function(items) {
if (!items.length) return ''; if (!items.length) return '';
return formatTimestamp(items[0].parsed.x || items[0].label); return formatTimestamp(items[0].label);
} }
} }
} }
@@ -212,7 +212,7 @@
} }
// --- System charts --- // --- System charts ---
let systemRange = '24h'; let systemRange = '1h';
let chartCPU, chartMem, chartTemp, chartLoad; let chartCPU, chartMem, chartTemp, chartLoad;
function initSystemCharts() { function initSystemCharts() {
@@ -363,7 +363,7 @@
// --- Container detail --- // --- Container detail ---
let detailChartCPU, detailChartMem; let detailChartCPU, detailChartMem;
let detailContainer = ''; let detailContainer = '';
let detailRange = '24h'; let detailRange = '1h';
function initDetailCharts() { function initDetailCharts() {
const mkChart = (id, color, yLabel) => { const mkChart = (id, color, yLabel) => {