Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docker info metricset to use V2 reporter #14746

Merged
merged 1 commit into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions metricbeat/module/docker/info/_meta/data.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
{
"@timestamp": "2017-10-12T08:05:34.853Z",
"beat": {
"hostname": "host.example.com",
"name": "host.example.com"
},
"docker": {
"info": {
"containers": {
"paused": 0,
"running": 29,
"stopped": 19,
"total": 48
"running": 2,
"stopped": 12,
"total": 14
},
"id": "V727:GUJU:KXA5:Y5YS:RYFT:6IYQ:GQN7:IGGT:O4YO:NRU3:ZIRV:MHEJ",
"images": 168
"id": "VF5E:SKD6:YFIG:VDGO:JU3M:ZT2N:4E6B:7IOL:5QOS:M3HT:EM7E:VL22",
"images": 425
}
},
"event": {
"dataset": "docker.info",
"duration": 115000,
"module": "docker"
},
"metricset": {
"host": "/var/run/docker.sock",
"module": "docker",
"name": "info",
"rtt": 115
"period": 10000
},
"service": {
"address": "/var/run/docker.sock",
"type": "docker"
}
}
12 changes: 6 additions & 6 deletions metricbeat/module/docker/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/docker/docker/client"

"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/metricbeat/mb"
"github.com/elastic/beats/metricbeat/module/docker"
)
Expand Down Expand Up @@ -59,17 +58,18 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {

// Fetch creates a new event for info.
// See: https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/display-system-wide-information
func (m *MetricSet) Fetch() (common.MapStr, error) {
func (m *MetricSet) Fetch(r mb.ReporterV2) error {
info, err := m.dockerClient.Info(context.TODO())
if err != nil {
return nil, err
return err
}

return eventMapping(&info), nil
r.Event(mb.Event{MetricSetFields: eventMapping(&info)})

return nil
}

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

return m.dockerClient.Close()
}
6 changes: 3 additions & 3 deletions metricbeat/module/docker/info/info_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
)

func TestData(t *testing.T) {
f := mbtest.NewEventFetcher(t, getConfig())
err := mbtest.WriteEvent(f, t)
if err != nil {
f := mbtest.NewReportingMetricSetV2Error(t, getConfig())

if err := mbtest.WriteEventsReporterV2Error(f, t, ""); err != nil {
t.Fatal("write", err)
}
}
Expand Down