Skip to content

Commit

Permalink
Return nil instead or an error if no metrics
Browse files Browse the repository at this point in the history
The docker metricset returns an error when there are no memory metric
values available.

This condition can happen when there are no running containers on
Docker.

When no containers are running, the metricset returns an error
at every collection, creating noise.
  • Loading branch information
zmoog committed Jun 5, 2024
1 parent adb0fb5 commit cf5f30f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion metricbeat/module/docker/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) error {

memoryStats := m.memoryService.getMemoryStatsList(stats, m.dedot)
if len(memoryStats) == 0 {
return fmt.Errorf("No memory stats data available")
// No memory stats available, probably because
// no containers are running.
return nil
}
eventsMapping(r, memoryStats)

Expand Down

0 comments on commit cf5f30f

Please sign in to comment.