Check the length before using container.Stats

This commit is contained in:
Guoliang Wang 2018-07-19 13:40:26 +08:00
parent 97fcafeb0b
commit 910de81342

View File

@ -953,6 +953,9 @@ func (c *PrometheusCollector) collectContainersInfo(ch chan<- prometheus.Metric)
} }
// Now for the actual metrics // Now for the actual metrics
if len(container.Stats) == 0 {
continue
}
stats := container.Stats[0] stats := container.Stats[0]
for _, cm := range c.containerMetrics { for _, cm := range c.containerMetrics {
if cm.condition != nil && !cm.condition(container.Spec) { if cm.condition != nil && !cm.condition(container.Spec) {