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: use 24h window for MetricSamples (matches in-memory retention)

rcourtman5877ce00c3cb
diff --git a/internal/ai/context/builder.go b/internal/ai/context/builder.go
index 26b19873ec..5944486b80 100644
--- a/internal/ai/context/builder.go
+++ b/internal/ai/context/builder.go
@@ -478,16 +478,17 @@ func (b *Builder) computeGuestMetricSamples(guestID string) map[string][]MetricP
return samples
}
- // Get 7 days of data - enough to see weekly patterns and determine normalcy
- allMetrics := b.metricsHistory.GetAllGuestMetrics(guestID, b.trendWindow7d)
+ // Get 24 hours of data (matches in-memory retention)
+ // This lets the LLM see recent patterns and changes
+ allMetrics := b.metricsHistory.GetAllGuestMetrics(guestID, b.trendWindow24h)
for metric, points := range allMetrics {
if len(points) < 3 {
continue
}
- // Downsample to ~24 points (roughly 3 per day over 7 days)
- // This lets the LLM see: daily patterns, weekly cycles, and recent changes
- sampled := DownsampleMetrics(points, 24)
+ // Downsample to ~12 points (roughly every 2 hours over 24h)
+ // This gives the LLM a compact view of recent trends
+ sampled := DownsampleMetrics(points, 12)
if len(sampled) >= 3 {
samples[metric] = sampled
}
diff --git a/internal/ai/context/formatter.go b/internal/ai/context/formatter.go
index ccd9f19f70..18d189e0e4 100644
--- a/internal/ai/context/formatter.go
+++ b/internal/ai/context/formatter.go
@@ -64,7 +64,7 @@ func FormatResourceContext(ctx ResourceContext) string {
// Raw metric samples - let the LLM interpret patterns directly
// This is more reliable than pre-computed trends for edge cases
if len(ctx.MetricSamples) > 0 {
- sb.WriteString("**History (7d sampled, oldest→newest)**: ")
+ sb.WriteString("**History (24h sampled, oldest→newest)**: ")
var sampleLines []string
for metric, points := range ctx.MetricSamples {
if len(points) >= 3 {