diff --git a/pkg/models/metrics/namespaces.go b/pkg/models/metrics/namespaces.go index 981e46911..5125cc168 100644 --- a/pkg/models/metrics/namespaces.go +++ b/pkg/models/metrics/namespaces.go @@ -40,6 +40,9 @@ func GetNamespacesWithMetrics(namespaces []*v1.Namespace) []*v1.Namespace { } rawMetrics := GetNamespaceMetrics(params) + if rawMetrics == nil { + return namespaces + } for _, result := range rawMetrics.Results { for _, data := range result.Data.Result { diff --git a/pkg/models/metrics/util.go b/pkg/models/metrics/util.go index b332ced4f..bead04ff4 100644 --- a/pkg/models/metrics/util.go +++ b/pkg/models/metrics/util.go @@ -68,7 +68,7 @@ func (rawMetrics *Response) SortBy(sortMetricName string, sortType string) (*Res } }() - if sortMetricName == "" { + if sortMetricName == "" || rawMetrics == nil { return rawMetrics, -1 }