Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Fix sparkline data inconsistency and support 30d range

rcourtman5a990dd5542a
diff --git a/frontend-modern/src/api/charts.ts b/frontend-modern/src/api/charts.ts
index 827455228b..11f224b25e 100644
--- a/frontend-modern/src/api/charts.ts
+++ b/frontend-modern/src/api/charts.ts
@@ -79,7 +79,7 @@ export interface AllMetricsHistoryResponse {
source?: 'store' | 'memory' | 'live';
}
-export type TimeRange = '5m' | '15m' | '30m' | '1h' | '4h' | '12h' | '24h' | '7d';
+export type TimeRange = '5m' | '15m' | '30m' | '1h' | '4h' | '12h' | '24h' | '7d' | '30d';
export class ChartsAPI {
private static baseUrl = '/api';
diff --git a/frontend-modern/src/stores/metricsHistory.ts b/frontend-modern/src/stores/metricsHistory.ts
index 0a5643e72f..fd85c5d842 100644
--- a/frontend-modern/src/stores/metricsHistory.ts
+++ b/frontend-modern/src/stores/metricsHistory.ts
@@ -23,11 +23,11 @@ interface RingBuffer {
}
// Configuration
-const MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000; // 7 days (to support all time ranges)
+const MAX_AGE_MS = 30 * 24 * 60 * 60 * 1000; // 30 days (to support all time ranges)
const SAMPLE_INTERVAL_MS = 30 * 1000; // 30 seconds
-const MAX_POINTS = Math.ceil(MAX_AGE_MS / SAMPLE_INTERVAL_MS); // ~2880 points
+const MAX_POINTS = Math.ceil(MAX_AGE_MS / SAMPLE_INTERVAL_MS); // ~86400 points
const STORAGE_KEY = 'pulse_metrics_history';
-const STORAGE_VERSION = 2; // Bumped version due to increased buffer size
+const STORAGE_VERSION = 3; // Bumped version due to increased buffer size
/**
* Convert TimeRange string to milliseconds
@@ -42,6 +42,7 @@ function timeRangeToMs(range: TimeRange): number {
case '12h': return 12 * 60 * 60 * 1000;
case '24h': return 24 * 60 * 60 * 1000;
case '7d': return 7 * 24 * 60 * 60 * 1000;
+ case '30d': return 30 * 24 * 60 * 60 * 1000;
default: return 60 * 60 * 1000; // Default 1h
}
}
diff --git a/internal/api/charts_test.go b/internal/api/charts_test.go
index 85a7eb86c0..e3467f3038 100644
--- a/internal/api/charts_test.go
+++ b/internal/api/charts_test.go
@@ -212,6 +212,7 @@ func TestTimeRangeConversion(t *testing.T) {
{"12h", 12 * time.Hour},
{"24h", 24 * time.Hour},
{"7d", 7 * 24 * time.Hour},
+ {"30d", 30 * 24 * time.Hour},
{"", time.Hour}, // default
{"invalid", time.Hour}, // fallback
}
@@ -237,6 +238,8 @@ func TestTimeRangeConversion(t *testing.T) {
duration = 24 * time.Hour
case "7d":
duration = 7 * 24 * time.Hour
+ case "30d":
+ duration = 30 * 24 * time.Hour
default:
duration = time.Hour
}
diff --git a/internal/api/router.go b/internal/api/router.go
index 665baaace0..87aa2b369a 100644
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@ -5024,6 +5024,8 @@ func (r *Router) handleCharts(w http.ResponseWriter, req *http.Request) {
duration = 24 * time.Hour
case "7d":
duration = 7 * 24 * time.Hour
+ case "30d":
+ duration = 30 * 24 * time.Hour
default:
duration = time.Hour
}
diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.go
index ec326b7c7a..a0f65a848e 100644
--- a/internal/monitoring/monitor.go
+++ b/internal/monitoring/monitor.go
@@ -3643,8 +3643,8 @@ func New(cfg *config.Config) (*Monitor, error) {
hostMetadataStore: config.NewHostMetadataStore(cfg.DataPath, nil),
startTime: time.Now(),
rateTracker: NewRateTracker(),
- metricsHistory: NewMetricsHistory(1000, 24*time.Hour), // Keep up to 1000 points or 24 hours
- metricsStore: metricsStore, // Persistent SQLite storage
+ metricsHistory: NewMetricsHistory(86400, 30*24*time.Hour), // Keep up to 86400 points (30 days @ 30s)
+ metricsStore: metricsStore, // Persistent SQLite storage
alertManager: alerts.NewManagerWithDataDir(cfg.DataPath),
incidentStore: incidentStore,
notificationMgr: notifications.NewNotificationManagerWithDataDir(cfg.PublicURL, cfg.DataPath),