From 5a8e029005f39421813ed8b94efd29ace2e37309 Mon Sep 17 00:00:00 2001 From: Alex <33497058+bexsoft@users.noreply.github.com> Date: Thu, 9 Jun 2022 17:52:12 -0500 Subject: [PATCH] Added Initial Time support to Prometheus dashboard (#2099) Incremented initial time for data usage growth chart --- restapi/admin_info.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/restapi/admin_info.go b/restapi/admin_info.go index 63b3affe47..31a49efa7a 100644 --- a/restapi/admin_info.go +++ b/restapi/admin_info.go @@ -127,6 +127,7 @@ type Target struct { Interval string LegendFormat string Step int32 + InitialTime int64 } type ReduceOptions struct { @@ -294,6 +295,8 @@ var widgets = []Metric{ { Expr: `sum(minio_bucket_usage_total_bytes{$__query}) by (instance)`, LegendFormat: "Used Capacity", + InitialTime: -180, + Step: 10, }, }, }, @@ -1046,7 +1049,15 @@ LabelsWaitLoop: apiType := "query_range" now := time.Now() - extraParamters := fmt.Sprintf("&start=%d&end=%d", now.Add(-15*time.Minute).Unix(), now.Unix()) + var initTime int64 = -15 + + if target.InitialTime != 0 { + initTime = target.InitialTime + } + + timeCalculated := time.Duration(initTime * int64(time.Minute)) + + extraParamters := fmt.Sprintf("&start=%d&end=%d", now.Add(timeCalculated).Unix(), now.Unix()) var step int32 = 60 if target.Step > 0 {