diff --git a/cmd/collectors/restperf/restperf.go b/cmd/collectors/restperf/restperf.go index 121140c90..99e24df35 100644 --- a/cmd/collectors/restperf/restperf.go +++ b/cmd/collectors/restperf/restperf.go @@ -1402,6 +1402,8 @@ func (r *RestPerf) pollInstance(records []gjson.Result) (map[string]*matrix.Matr if oldInstances.Has(instanceKey) { // instance already in cache oldInstances.Remove(instanceKey) + instance := mat.GetInstance(instanceKey) + r.updateQosLabels(instanceData, instance, instanceKey) r.Logger.Debug().Msgf("updated instance [%s%s%s%s]", color.Bold, color.Yellow, instanceKey, color.End) } else if instance, err := mat.NewInstance(instanceKey); err != nil { r.Logger.Error().Err(err).Str("instanceKey", instanceKey).Msg("add instance") @@ -1409,18 +1411,7 @@ func (r *RestPerf) pollInstance(records []gjson.Result) (map[string]*matrix.Matr r.Logger.Trace(). Str("key", instanceKey). Msg("Added new instance") - if isWorkloadObject(r.Prop.Query) || isWorkloadDetailObject(r.Prop.Query) { - for label, display := range r.perfProp.qosLabels { - if value := instanceData.Get(label); value.Exists() { - instance.SetLabel(display, strings.Clone(value.String())) - } else { - // lun,file,qtree may not always exist for workload - r.Logger.Trace().Str("label", label).Str("instanceKey", instanceKey).Msg("Missing label") - - } - } - r.Logger.Debug().Str("query", r.Prop.Query).Str("key", instanceKey).Str("qos labels", instance.GetLabels().String()).Msg("") - } + r.updateQosLabels(instanceData, instance, instanceKey) } } @@ -1442,6 +1433,20 @@ func (r *RestPerf) pollInstance(records []gjson.Result) (map[string]*matrix.Matr return nil, err } +func (r *RestPerf) updateQosLabels(qos gjson.Result, instance *matrix.Instance, key string) { + if isWorkloadObject(r.Prop.Query) || isWorkloadDetailObject(r.Prop.Query) { + for label, display := range r.perfProp.qosLabels { + if value := qos.Get(label); value.Exists() { + instance.SetLabel(display, strings.Clone(value.String())) + } else { + // lun,file,qtree may not always exist for workload + r.Logger.Trace().Str("label", label).Str("key", key).Msg("Missing label") + } + } + r.Logger.Debug().Str("query", r.Prop.Query).Str("key", key).Str("qos labels", instance.GetLabels().String()).Send() + } +} + func (r *RestPerf) handleError(err error, href string) (map[string]*matrix.Matrix, error) { if errs.IsRestErr(err, errs.TableNotFound) || errs.IsRestErr(err, errs.APINotFound) { // the table or API does not exist. return ErrAPIRequestRejected so the task goes to stand-by diff --git a/cmd/collectors/zapiperf/zapiperf.go b/cmd/collectors/zapiperf/zapiperf.go index 35bf4926e..382510a91 100644 --- a/cmd/collectors/zapiperf/zapiperf.go +++ b/cmd/collectors/zapiperf/zapiperf.go @@ -1468,6 +1468,8 @@ func (z *ZapiPerf) PollInstance() (map[string]*matrix.Matrix, error) { } else if oldInstances.Has(key) { // instance already in cache oldInstances.Remove(key) + instance := mat.GetInstance(key) + z.updateQosLabels(i, instance, key) z.Logger.Trace().Msgf("updated instance [%s%s%s%s]", color.Bold, color.Yellow, key, color.End) continue } else if instance, err := mat.NewInstance(key); err != nil { @@ -1476,14 +1478,7 @@ func (z *ZapiPerf) PollInstance() (map[string]*matrix.Matrix, error) { z.Logger.Trace(). Str("key", key). Msg("Added new instance") - if z.Query == objWorkload || z.Query == objWorkloadDetail || z.Query == objWorkloadVolume || z.Query == objWorkloadDetailVolume { - for label, display := range z.qosLabels { - if value := i.GetChildContentS(label); value != "" { - instance.SetLabel(display, value) - } - } - z.Logger.Debug().Msgf("(%s) [%s] added QOS labels: %s", z.Query, key, instance.GetLabels().String()) - } + z.updateQosLabels(i, instance, key) } } } @@ -1506,6 +1501,17 @@ func (z *ZapiPerf) PollInstance() (map[string]*matrix.Matrix, error) { return nil, err } +func (z *ZapiPerf) updateQosLabels(qos *node.Node, instance *matrix.Instance, key string) { + if z.Query == objWorkload || z.Query == objWorkloadDetail || z.Query == objWorkloadVolume || z.Query == objWorkloadDetailVolume { + for label, display := range z.qosLabels { + if value := qos.GetChildContentS(label); value != "" { + instance.SetLabel(display, value) + } + } + z.Logger.Debug().Str("query", z.Query).Str("key", key).Str("qos labels", instance.GetLabels().String()).Send() + } +} + // Interface guards var ( _ collector.Collector = (*ZapiPerf)(nil)