From 4e3945c1f299f0f5e9cd0fff899c25121fd3599d Mon Sep 17 00:00:00 2001 From: Hardikl <83282894+Hardikl@users.noreply.github.com> Date: Fri, 9 Aug 2024 00:15:59 +0530 Subject: [PATCH] fix: remove threshold from quota rest template (#3093) * fix: remove threshold from quota rest template * fix: handled threshold metric in quota plugin * fix: handled review comment * refactor: remove stack trace --------- Co-authored-by: Chris Grindstaff --- cmd/collectors/rest/plugins/quota/quota.go | 12 ++++++++++++ conf/rest/9.12.0/quota.yaml | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/collectors/rest/plugins/quota/quota.go b/cmd/collectors/rest/plugins/quota/quota.go index 1f026d392..7f66e9622 100644 --- a/cmd/collectors/rest/plugins/quota/quota.go +++ b/cmd/collectors/rest/plugins/quota/quota.go @@ -16,6 +16,10 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { } func (q *Quota) Init() error { + if err := q.InitAbc(); err != nil { + return err + } + if q.Params.HasChildS("qtreeMetrics") { q.qtreeMetrics = true } @@ -25,6 +29,14 @@ func (q *Quota) Init() error { func (q *Quota) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *util.Metadata, error) { data := dataMap[q.Object] + // The threshold metric does not exist in REST quota template, we are adding it to maintain parity with exported ZAPI metrics + if data.GetMetric("threshold") == nil { + _, err := data.NewMetricFloat64("threshold", "threshold") + if err != nil { + q.Logger.Error().Err(err).Msg("add metric") + } + } + // Purge and reset data instanceMap := data.GetInstances() metricsMap := data.GetMetrics() diff --git a/conf/rest/9.12.0/quota.yaml b/conf/rest/9.12.0/quota.yaml index ca8304073..00e6d8753 100644 --- a/conf/rest/9.12.0/quota.yaml +++ b/conf/rest/9.12.0/quota.yaml @@ -23,7 +23,6 @@ counters: - space.used.hard_limit_percent => disk_used_pct_disk_limit - space.used.soft_limit_percent => disk_used_pct_soft_disk_limit - space.used.total => disk_used - - threshold => threshold - filter: - show_default_records=false - type=tree #|user|group