Skip to content

Commit

Permalink
[metricbeat] implement Close() for docker metricsets (#11294) (#11340)
Browse files Browse the repository at this point in the history
* implement Close() for docker metricsets

(cherry picked from commit 57f8b5c)
  • Loading branch information
fearful-symmetry committed Mar 21, 2019
1 parent 9ac3a4d commit ffd4067
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ https://github.com/elastic/beats/compare/v7.0.0-beta1...master[Check the HEAD di
- Add documentation about jolokia autodiscover fields. {issue}10925[10925] {pull}10979[10979]
- Add missing aws.ec2.instance.state.name into fields.yml. {issue}11219[11219] {pull}11221[11221]
- Fix ec2 metricset to collect metrics from Cloudwatch with the same timestamp. {pull}11142[11142]
- Fix potential memory leak in stopped docker metricsets {pull}11294[11294]

*Packetbeat*

Expand Down
7 changes: 7 additions & 0 deletions metricbeat/module/docker/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func init() {
)
}

// MetricSet type defines all fields of the MetricSet
type MetricSet struct {
mb.BaseMetricSet
dockerClient *client.Client
Expand Down Expand Up @@ -76,3 +77,9 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) {
}
eventsMapping(r, containers, m.dedot)
}

//Close stops the metricset
func (m *MetricSet) Close() error {

return m.dockerClient.Close()
}
6 changes: 6 additions & 0 deletions metricbeat/module/docker/cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,9 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) {
formattedStats := m.cpuService.getCPUStatsList(stats, m.dedot)
eventsMapping(r, formattedStats)
}

//Close stops the metricset
func (m *MetricSet) Close() error {

return m.dockerClient.Close()
}
6 changes: 6 additions & 0 deletions metricbeat/module/docker/diskio/diskio.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,9 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) {
formattedStats := m.blkioService.getBlkioStatsList(stats, m.dedot)
eventsMapping(r, formattedStats)
}

//Close stops the metricset
func (m *MetricSet) Close() error {

return m.dockerClient.Close()
}
6 changes: 6 additions & 0 deletions metricbeat/module/docker/healthcheck/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,9 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) {
}
eventsMapping(r, containers, m)
}

//Close stops the metricset
func (m *MetricSet) Close() error {

return m.dockerClient.Close()
}
6 changes: 6 additions & 0 deletions metricbeat/module/docker/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,9 @@ func (m *MetricSet) Fetch() ([]common.MapStr, error) {

return eventsMapping(images, m.dedot), nil
}

//Close stops the metricset
func (m *MetricSet) Close() error {

return m.dockerClient.Close()
}
6 changes: 6 additions & 0 deletions metricbeat/module/docker/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,9 @@ func (m *MetricSet) Fetch() (common.MapStr, error) {

return eventMapping(&info), nil
}

//Close stops the metricset
func (m *MetricSet) Close() error {

return m.dockerClient.Close()
}
6 changes: 6 additions & 0 deletions metricbeat/module/docker/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,9 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) {
memoryStats := m.memoryService.getMemoryStatsList(stats, m.dedot)
eventsMapping(r, memoryStats)
}

//Close stops the metricset
func (m *MetricSet) Close() error {

return m.dockerClient.Close()
}
6 changes: 6 additions & 0 deletions metricbeat/module/docker/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,9 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) {
formattedStats := m.netService.getNetworkStatsPerContainer(stats, m.dedot)
eventsMapping(r, formattedStats)
}

//Close stops the metricset
func (m *MetricSet) Close() error {

return m.dockerClient.Close()
}

0 comments on commit ffd4067

Please sign in to comment.