diff --git a/cmd/collectors/rest/plugins/volume/volume.go b/cmd/collectors/rest/plugins/volume/volume.go index 95f700249..9e70cd01e 100644 --- a/cmd/collectors/rest/plugins/volume/volume.go +++ b/cmd/collectors/rest/plugins/volume/volume.go @@ -177,12 +177,13 @@ func (v *Volume) updateVolumeLabels(data *matrix.Matrix, volumeMap map[string]vo capacityTierFootprintMetric := data.GetMetric("volume_blocks_footprint_bin1") totalFootprintMetric := data.GetMetric("total_footprint") - hotDataMetric := data.GetMetric("hot_data") - if hotDataMetric == nil { - if hotDataMetric, err = data.NewMetricFloat64("hot_data"); err != nil { - v.SLogger.Error("error while creating hot data metric", slogx.Err(err)) - return + if capacityTierFootprintMetric != nil && totalFootprintMetric != nil { + if hotDataMetric == nil { + if hotDataMetric, err = data.NewMetricFloat64("hot_data"); err != nil { + v.SLogger.Error("error while creating hot data metric", slogx.Err(err)) + return + } } } @@ -227,7 +228,7 @@ func (v *Volume) updateVolumeLabels(data *matrix.Matrix, volumeMap map[string]vo } // Calculate Hot data metric, where hot data = total footprint - cold data - if capacityTierFootprintMetric != nil { + if capacityTierFootprintMetric != nil && totalFootprintMetric != nil { if capacityTierFootprintMetricValue, exist := capacityTierFootprintMetric.GetValueFloat64(volume); exist { totalFootprintMetricValue, _ := totalFootprintMetric.GetValueFloat64(volume) hotDataMetric.SetValueFloat64(volume, totalFootprintMetricValue-capacityTierFootprintMetricValue) diff --git a/cmd/collectors/volume.go b/cmd/collectors/volume.go index f19a7bf78..bbfaa2951 100644 --- a/cmd/collectors/volume.go +++ b/cmd/collectors/volume.go @@ -245,9 +245,11 @@ func ProcessFlexGroupFootPrint(data *matrix.Matrix, logger *slog.Logger) *matrix totalFootprintMetric := cache.GetMetric("total_footprint") hotDataMetric := cache.GetMetric("hot_data") - if hotDataMetric == nil { - if hotDataMetric, err = cache.NewMetricFloat64("hot_data"); err != nil { - logger.Error("error while creating hot data metric", slogx.Err(err)) + if capacityTierFootprintMetric != nil && totalFootprintMetric != nil { + if hotDataMetric == nil { + if hotDataMetric, err = cache.NewMetricFloat64("hot_data"); err != nil { + logger.Error("error while creating hot data metric", slogx.Err(err)) + } } } @@ -324,7 +326,7 @@ func ProcessFlexGroupFootPrint(data *matrix.Matrix, logger *slog.Logger) *matrix } // Calculate Hot data metric, where hot data = total footprint - cold data - if capacityTierFootprintMetric != nil { + if capacityTierFootprintMetric != nil && totalFootprintMetric != nil { if capacityTierFootprintMetricValue, exist := capacityTierFootprintMetric.GetValueFloat64(fg); exist { totalFootprintMetricValue, _ := totalFootprintMetric.GetValueFloat64(fg) hotDataMetric.SetValueFloat64(fg, totalFootprintMetricValue-capacityTierFootprintMetricValue) diff --git a/cmd/collectors/zapi/plugins/volume/volume.go b/cmd/collectors/zapi/plugins/volume/volume.go index 6f4b3744d..12b62ff88 100644 --- a/cmd/collectors/zapi/plugins/volume/volume.go +++ b/cmd/collectors/zapi/plugins/volume/volume.go @@ -302,7 +302,7 @@ func (v *Volume) getVolumeFootprint() (map[string]map[string]string, error) { footprintMetrics["guarantee_footprint"] = volumeBlocksFootprint // Calculate Hot data metric, where hot data = total footprint - cold data - if capacityTierFootprint != "" { + if capacityTierFootprint != "" && totalFootprint != "" { totalFootprintVal, _ := strconv.ParseFloat(totalFootprint, 64) capacityTierFootprintVal, _ := strconv.ParseFloat(capacityTierFootprint, 64) footprintMetrics["hot_data"] = strconv.FormatFloat(totalFootprintVal-capacityTierFootprintVal, 'f', -1, 64)