diff --git a/telemetry/README.md b/telemetry/README.md index 6e1db0aeb..f07f43b88 100644 --- a/telemetry/README.md +++ b/telemetry/README.md @@ -177,6 +177,9 @@ GET /api/metrics?days=30 # Get one cluster's daily usage history (disk bytes, volumes, volume servers) GET /api/history?cluster_id=&days=90 + +# Get per-cluster disk usage over time, largest first, the rest summed as "other" +GET /api/cluster-sizes?days=30&limit=20 ``` ### Monitoring diff --git a/telemetry/server/api/handlers.go b/telemetry/server/api/handlers.go index b3faf234d..a4c767ebc 100644 --- a/telemetry/server/api/handlers.go +++ b/telemetry/server/api/handlers.go @@ -150,6 +150,30 @@ func (h *Handler) GetMetrics(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(metrics) } +func (h *Handler) GetClusterSizes(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodGet { + http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) + return + } + + days := 30 // default + if daysStr := r.URL.Query().Get("days"); daysStr != "" { + if d, err := strconv.Atoi(daysStr); err == nil && d > 0 && d <= 365 { + days = d + } + } + + limit := 20 // default + if limitStr := r.URL.Query().Get("limit"); limitStr != "" { + if l, err := strconv.Atoi(limitStr); err == nil && l > 0 && l <= 1000 { + limit = l + } + } + + w.Header().Set("Content-Type", "application/json") + json.NewEncoder(w).Encode(h.storage.GetClusterSizeSeries(days, limit)) +} + func (h *Handler) GetHistory(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) diff --git a/telemetry/server/dashboard/dashboard.go b/telemetry/server/dashboard/dashboard.go index 78301acc5..c977c4101 100644 --- a/telemetry/server/dashboard/dashboard.go +++ b/telemetry/server/dashboard/dashboard.go @@ -69,6 +69,10 @@ func (h *Handler) ServeIndex(w http.ResponseWriter, r *http.Request) { font-weight: bold; margin-bottom: 15px; } + .chart-subtitle { + color: #666; + margin: -10px 0 15px; + } .loading { text-align: center; padding: 40px; @@ -159,6 +163,14 @@ func (h *Handler) ServeIndex(w http.ResponseWriter, r *http.Request) { +
+
Cluster Sizes Over Time
+
+
+ +
+
+
Per-Cluster History
@@ -177,6 +189,7 @@ func (h *Handler) ServeIndex(w http.ResponseWriter, r *http.Request) {