From b91cb0ad8d2a2a84532e95d99311a4f6489d7338 Mon Sep 17 00:00:00 2001 From: Douae Jeouit Date: Mon, 30 Jan 2017 17:14:40 +0100 Subject: [PATCH 01/14] Create image metricset update templates add data.json add docs check to test_docker.py update CHANGELOG.asciidoc make update - make fmt - make collect --- CHANGELOG.asciidoc | 2 + metricbeat/docs/fields.asciidoc | 15 +++++ metricbeat/docs/modules/docker.asciidoc | 4 ++ metricbeat/include/list.go | 1 + metricbeat/metricbeat.template-es2x.json | 9 +++ metricbeat/metricbeat.template.json | 8 +++ .../module/docker/image/_meta/data.json | 19 ++++++ .../module/docker/image/_meta/docs.asciidoc | 3 + .../module/docker/image/_meta/fields.yml | 9 +++ metricbeat/module/docker/image/data.go | 36 +++++++++++ metricbeat/module/docker/image/image.go | 63 +++++++++++++++++++ .../docker/image/image_integration_test.go | 23 +++++++ metricbeat/tests/system/test_docker.py | 34 ++++++++-- 13 files changed, 222 insertions(+), 4 deletions(-) create mode 100644 metricbeat/module/docker/image/_meta/data.json create mode 100644 metricbeat/module/docker/image/_meta/docs.asciidoc create mode 100644 metricbeat/module/docker/image/_meta/fields.yml create mode 100644 metricbeat/module/docker/image/data.go create mode 100644 metricbeat/module/docker/image/image.go create mode 100644 metricbeat/module/docker/image/image_integration_test.go diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 678caecde7ca..07294e343775 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -88,6 +88,7 @@ https://github.com/elastic/beats/compare/v5.1.1...master[Check the HEAD diff] - Kafka consumer groups metricset. {pull}3240[3240] - Add dynamic configuration reloading for modules. {pull}3281[3281] - Add docker health metricset {pull}3357[3357] +- Add docker image metricset {pull}3467[3467] - System module uses new matchers for white-listing processes. {pull}3469[3469] *Packetbeat* @@ -165,6 +166,7 @@ https://github.com/elastic/beats/compare/v5.0.2...v5.1.1[View commits] - Add raw config option for mysql/status metricset. {pull}3001[3001] - Add command fields for mysql/status metricset. {pull}3251[3251] + *Filebeat* - Add command line option `-once` to run Filebeat only once and then close. {pull}2456[2456] diff --git a/metricbeat/docs/fields.asciidoc b/metricbeat/docs/fields.asciidoc index 7eb7d5a5bb30..0e5b5256c5fd 100644 --- a/metricbeat/docs/fields.asciidoc +++ b/metricbeat/docs/fields.asciidoc @@ -1392,6 +1392,21 @@ type: integer Healthcheck status code +[float] +== image Fields + +image + + + +[float] +=== docker.image.example + +type: keyword + +Example field + + [float] == info Fields diff --git a/metricbeat/docs/modules/docker.asciidoc b/metricbeat/docs/modules/docker.asciidoc index 2388f6ea9e0b..2d11ff9b87b1 100644 --- a/metricbeat/docs/modules/docker.asciidoc +++ b/metricbeat/docs/modules/docker.asciidoc @@ -46,6 +46,8 @@ The following metricsets are available: * <> +* <> + * <> * <> @@ -60,6 +62,8 @@ include::docker/diskio.asciidoc[] include::docker/healthcheck.asciidoc[] +include::docker/image.asciidoc[] + include::docker/info.asciidoc[] include::docker/memory.asciidoc[] diff --git a/metricbeat/include/list.go b/metricbeat/include/list.go index c14b44877088..f3d421e50ce0 100644 --- a/metricbeat/include/list.go +++ b/metricbeat/include/list.go @@ -21,6 +21,7 @@ import ( _ "github.com/elastic/beats/metricbeat/module/docker/cpu" _ "github.com/elastic/beats/metricbeat/module/docker/diskio" _ "github.com/elastic/beats/metricbeat/module/docker/healthcheck" + _ "github.com/elastic/beats/metricbeat/module/docker/image" _ "github.com/elastic/beats/metricbeat/module/docker/info" _ "github.com/elastic/beats/metricbeat/module/docker/memory" _ "github.com/elastic/beats/metricbeat/module/docker/network" diff --git a/metricbeat/metricbeat.template-es2x.json b/metricbeat/metricbeat.template-es2x.json index 2eb265d1386d..15dcb13b787b 100644 --- a/metricbeat/metricbeat.template-es2x.json +++ b/metricbeat/metricbeat.template-es2x.json @@ -810,6 +810,15 @@ } } }, + "image": { + "properties": { + "example": { + "ignore_above": 1024, + "index": "not_analyzed", + "type": "string" + } + } + }, "info": { "properties": { "containers": { diff --git a/metricbeat/metricbeat.template.json b/metricbeat/metricbeat.template.json index f4da00f229a2..7520488bd284 100644 --- a/metricbeat/metricbeat.template.json +++ b/metricbeat/metricbeat.template.json @@ -806,6 +806,14 @@ } } }, + "image": { + "properties": { + "example": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, "info": { "properties": { "containers": { diff --git a/metricbeat/module/docker/image/_meta/data.json b/metricbeat/module/docker/image/_meta/data.json new file mode 100644 index 000000000000..0c3fadc2f75d --- /dev/null +++ b/metricbeat/module/docker/image/_meta/data.json @@ -0,0 +1,19 @@ +{ + "@timestamp":"2016-05-23T08:05:34.853Z", + "beat":{ + "hostname":"beathost", + "name":"beathost" + }, + "metricset":{ + "host":"localhost", + "module":"docker", + "name":"image", + "rtt":44269 + }, + "docker":{ + "image":{ + "example": "image" + } + }, + "type":"metricsets" +} diff --git a/metricbeat/module/docker/image/_meta/docs.asciidoc b/metricbeat/module/docker/image/_meta/docs.asciidoc new file mode 100644 index 000000000000..d78ba7a3d228 --- /dev/null +++ b/metricbeat/module/docker/image/_meta/docs.asciidoc @@ -0,0 +1,3 @@ +=== docker image MetricSet + +This is the image metricset of the module docker. diff --git a/metricbeat/module/docker/image/_meta/fields.yml b/metricbeat/module/docker/image/_meta/fields.yml new file mode 100644 index 000000000000..05297fca4aef --- /dev/null +++ b/metricbeat/module/docker/image/_meta/fields.yml @@ -0,0 +1,9 @@ +- name: image + type: group + description: > + image + fields: + - name: example + type: keyword + description: > + Example field diff --git a/metricbeat/module/docker/image/data.go b/metricbeat/module/docker/image/data.go new file mode 100644 index 000000000000..7a18c249a764 --- /dev/null +++ b/metricbeat/module/docker/image/data.go @@ -0,0 +1,36 @@ +package image + +import ( + "github.com/elastic/beats/libbeat/common" + + "github.com/elastic/beats/metricbeat/module/docker" + dc "github.com/fsouza/go-dockerclient" +) + +func eventsMapping(imagesList []dc.APIImages) []common.MapStr { + events := []common.MapStr{} + for _, image := range imagesList { + events = append(events, eventMapping(&image)) + } + return events +} + +func eventMapping(image *dc.APIImages) common.MapStr { + event := common.MapStr{ + "id": common.MapStr{ + "current": image.ID, + "parent": image.ParentID, + }, + "created": image.Created, + "size": common.MapStr{ + "regular": image.Size, + "virtual": image.VirtualSize, + }, + "repoTags": image.RepoTags, + } + labels := docker.DeDotLabels(image.Labels) + if len(labels) > 0 { + event["labels"] = labels + } + return event +} diff --git a/metricbeat/module/docker/image/image.go b/metricbeat/module/docker/image/image.go new file mode 100644 index 000000000000..ebac45441924 --- /dev/null +++ b/metricbeat/module/docker/image/image.go @@ -0,0 +1,63 @@ +package image + +import ( + "github.com/elastic/beats/libbeat/common" + "github.com/elastic/beats/libbeat/logp" + "github.com/elastic/beats/metricbeat/mb" + "github.com/elastic/beats/metricbeat/module/docker" + + dc "github.com/fsouza/go-dockerclient" +) + +// init registers the MetricSet with the central registry. +// The New method will be called after the setup of the module and before starting to fetch data +func init() { + if err := mb.Registry.AddMetricSet("docker", "image", New); err != nil { + panic(err) + } +} + +// MetricSet type defines all fields of the MetricSet +// As a minimum it must inherit the mb.BaseMetricSet fields, but can be extended with +// additional entries. These variables can be used to persist data or configuration between +// multiple fetch calls. +type MetricSet struct { + mb.BaseMetricSet + dockerClient *dc.Client +} + +// New create a new instance of the MetricSet +// Part of new is also setting up the configuration by processing additional +// configuration entries if needed. +func New(base mb.BaseMetricSet) (mb.MetricSet, error) { + + logp.Warn("EXPERIMENTAL: The docker info metricset is experimental") + + config := docker.Config{} + if err := base.Module().UnpackConfig(&config); err != nil { + return nil, err + } + + client, err := docker.NewDockerClient(base.HostData().URI, config) + if err != nil { + return nil, err + } + + return &MetricSet{ + BaseMetricSet: base, + dockerClient: client, + }, nil +} + +// Fetch methods implements the data gathering and data conversion to the right format +// It returns the event which is then forward to the output. In case of an error, a +// descriptive error must be returned. +func (m *MetricSet) Fetch() ([]common.MapStr, error) { + + images, err := m.dockerClient.ListImages(dc.ListImagesOptions{}) + if err != nil { + return nil, err + } + + return eventsMapping(images), nil +} diff --git a/metricbeat/module/docker/image/image_integration_test.go b/metricbeat/module/docker/image/image_integration_test.go new file mode 100644 index 000000000000..ce1cc38dbdba --- /dev/null +++ b/metricbeat/module/docker/image/image_integration_test.go @@ -0,0 +1,23 @@ +package image + +import ( + "testing" + + mbtest "github.com/elastic/beats/metricbeat/mb/testing" +) + +func TestData(t *testing.T) { + f := mbtest.NewEventFetcher(t, getConfig()) + err := mbtest.WriteEvent(f, t) + if err != nil { + t.Fatal("write", err) + } +} + +func getConfig() map[string]interface{} { + return map[string]interface{}{ + "module": "docker", + "metricsets": []string{"image"}, + "hosts": []string{"unix:///var/run/docker.sock"}, + } +} diff --git a/metricbeat/tests/system/test_docker.py b/metricbeat/tests/system/test_docker.py index 5c41f247fa7e..00e5e71ad27d 100644 --- a/metricbeat/tests/system/test_docker.py +++ b/metricbeat/tests/system/test_docker.py @@ -191,9 +191,35 @@ def test_health_fields(self): evt = self.remove_labels(evt) self.assert_fields_are_documented(evt) - def remove_labels(self, evt): + @unittest.skipUnless(metricbeat.INTEGRATION_TESTS, "integration test") + def test_container_fields(self): + """ + test image fields + """ + self.render_config_template(modules=[{ + "name": "docker", + "metricsets": ["image"], + "hosts": ["unix:///var/run/docker.sock"], + "period": "1s", + }]) + + proc = self.start_beat() + self.wait_until(lambda: self.output_lines() > 0, max_timeout=20) + proc.check_kill_and_wait() + + # Ensure no errors or warnings exist in the log. + log = self.get_log() + self.assertNotRegexpMatches(log.replace("WARN EXPERIMENTAL", ""), "ERR|WARN") + + output = self.read_output_json() + evt = output[0] + + evt = self.remove_labels(evt) + self.assert_fields_are_documented(evt) + +def remove_labels(self, evt): - if 'labels' in evt["docker"]["container"]: - del evt["docker"]["container"]["labels"] + if 'labels' in evt["docker"]["container"]: + del evt["docker"]["container"]["labels"] - return evt + return evt From 174aa0d980f40941d9eb5b6bf02e7169d017e635 Mon Sep 17 00:00:00 2001 From: Douae Jeouit Date: Mon, 30 Jan 2017 17:16:38 +0100 Subject: [PATCH 02/14] add image.asciidoc --- metricbeat/docs/modules/docker/image.asciidoc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 metricbeat/docs/modules/docker/image.asciidoc diff --git a/metricbeat/docs/modules/docker/image.asciidoc b/metricbeat/docs/modules/docker/image.asciidoc new file mode 100644 index 000000000000..2771f9273325 --- /dev/null +++ b/metricbeat/docs/modules/docker/image.asciidoc @@ -0,0 +1,19 @@ +//// +This file is generated! See scripts/docs_collector.py +//// + +[[metricbeat-metricset-docker-image]] +include::../../../module/docker/image/_meta/docs.asciidoc[] + + +==== Fields + +For a description of each field in the metricset, see the +<> section. + +Here is an example document generated by this metricset: + +[source,json] +---- +include::../../../module/docker/image/_meta/data.json[] +---- From a0d9ee1d9876487e39f9f32cb2cff93a7b06b5c5 Mon Sep 17 00:00:00 2001 From: Douae Jeouit Date: Mon, 30 Jan 2017 17:35:19 +0100 Subject: [PATCH 03/14] update CHANGELOG.asciidoc --- CHANGELOG.asciidoc | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 07294e343775..bbd4a9e1a9ed 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -166,7 +166,6 @@ https://github.com/elastic/beats/compare/v5.0.2...v5.1.1[View commits] - Add raw config option for mysql/status metricset. {pull}3001[3001] - Add command fields for mysql/status metricset. {pull}3251[3251] - *Filebeat* - Add command line option `-once` to run Filebeat only once and then close. {pull}2456[2456] From 7b51927f21e58154232213490693aee1e499c349 Mon Sep 17 00:00:00 2001 From: Douae Jeouit Date: Mon, 30 Jan 2017 17:40:59 +0100 Subject: [PATCH 04/14] Update image integration test --- metricbeat/module/docker/image/image_integration_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metricbeat/module/docker/image/image_integration_test.go b/metricbeat/module/docker/image/image_integration_test.go index ce1cc38dbdba..988927ab852e 100644 --- a/metricbeat/module/docker/image/image_integration_test.go +++ b/metricbeat/module/docker/image/image_integration_test.go @@ -7,8 +7,8 @@ import ( ) func TestData(t *testing.T) { - f := mbtest.NewEventFetcher(t, getConfig()) - err := mbtest.WriteEvent(f, t) + f := mbtest.NewEventsFetcher(t, getConfig()) + err := mbtest.WriteEvents(f, t) if err != nil { t.Fatal("write", err) } From f85fa23acfce9aa1ded9507cc0f2f1d8f42f3aad Mon Sep 17 00:00:00 2001 From: Douae Jeouit Date: Mon, 30 Jan 2017 18:24:46 +0100 Subject: [PATCH 05/14] update test_docker.py --- metricbeat/tests/system/test_docker.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/metricbeat/tests/system/test_docker.py b/metricbeat/tests/system/test_docker.py index 00e5e71ad27d..193ccbef8c3e 100644 --- a/metricbeat/tests/system/test_docker.py +++ b/metricbeat/tests/system/test_docker.py @@ -192,7 +192,7 @@ def test_health_fields(self): self.assert_fields_are_documented(evt) @unittest.skipUnless(metricbeat.INTEGRATION_TESTS, "integration test") - def test_container_fields(self): + def test_image_fields(self): """ test image fields """ @@ -217,9 +217,9 @@ def test_container_fields(self): evt = self.remove_labels(evt) self.assert_fields_are_documented(evt) -def remove_labels(self, evt): + def remove_labels(self, evt): - if 'labels' in evt["docker"]["container"]: - del evt["docker"]["container"]["labels"] + if 'labels' in evt["docker"]["container"]: + del evt["docker"]["container"]["labels"] - return evt + return evt From 261a0b09f6160343ba953348f4c684b122a7e113 Mon Sep 17 00:00:00 2001 From: Douae Jeouit Date: Wed, 1 Feb 2017 09:16:32 +0100 Subject: [PATCH 06/14] Update data: mesure & display the creation time of the image --- metricbeat/module/docker/image/data.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/metricbeat/module/docker/image/data.go b/metricbeat/module/docker/image/data.go index 7a18c249a764..312f1753614c 100644 --- a/metricbeat/module/docker/image/data.go +++ b/metricbeat/module/docker/image/data.go @@ -5,6 +5,7 @@ import ( "github.com/elastic/beats/metricbeat/module/docker" dc "github.com/fsouza/go-dockerclient" + "time" ) func eventsMapping(imagesList []dc.APIImages) []common.MapStr { @@ -21,7 +22,7 @@ func eventMapping(image *dc.APIImages) common.MapStr { "current": image.ID, "parent": image.ParentID, }, - "created": image.Created, + "created": common.Time(time.Unix(image.Created, 0)), "size": common.MapStr{ "regular": image.Size, "virtual": image.VirtualSize, From 3871ac84a594a1198e9a6d90947be8618b21b617 Mon Sep 17 00:00:00 2001 From: Douae Jeouit Date: Wed, 1 Feb 2017 09:56:07 +0100 Subject: [PATCH 07/14] complete the metricset documentation : update fields.yml --- .../module/docker/image/_meta/fields.yml | 40 +++++++++++++++++-- metricbeat/module/docker/image/data.go | 2 +- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/metricbeat/module/docker/image/_meta/fields.yml b/metricbeat/module/docker/image/_meta/fields.yml index 05297fca4aef..709f78f2df90 100644 --- a/metricbeat/module/docker/image/_meta/fields.yml +++ b/metricbeat/module/docker/image/_meta/fields.yml @@ -1,9 +1,41 @@ - name: image type: group description: > - image + Docker image metrics. fields: - - name: example - type: keyword + - name: id + type: group description: > - Example field + The image layers ID. + fields: + - name: current + type: keyword + description: > + Unique image ID given upon its creation. + - name: parent + type: keyword + description: > + ID of the image, if it exists, from which the current image directly descends. + - name: created + type: date + description: > + Date and time when the image was created. + - name: size + type: group + description: > + Image size layers. + fields: + - name: virtual + type: long + description: > + Size of the image. + - name: regular + type: long + description: > + Total size of the all cached images associated to the current image. + +# TODO : How to describe tags & labels list ? +# - name: tags +# type: list ? +# description: > +# Descriptive or given name(s) to the image. diff --git a/metricbeat/module/docker/image/data.go b/metricbeat/module/docker/image/data.go index 312f1753614c..877a3d7db639 100644 --- a/metricbeat/module/docker/image/data.go +++ b/metricbeat/module/docker/image/data.go @@ -27,7 +27,7 @@ func eventMapping(image *dc.APIImages) common.MapStr { "regular": image.Size, "virtual": image.VirtualSize, }, - "repoTags": image.RepoTags, + "tags": image.RepoTags, } labels := docker.DeDotLabels(image.Labels) if len(labels) > 0 { From 42f58cdbf7a9fdddab016a213a8ff2809fe2fa4d Mon Sep 17 00:00:00 2001 From: Douae Jeouit Date: Wed, 1 Feb 2017 09:59:52 +0100 Subject: [PATCH 08/14] update templates --- metricbeat/docs/fields.asciidoc | 52 ++++++++++++++++++++++-- metricbeat/metricbeat.template-es2x.json | 30 ++++++++++++-- metricbeat/metricbeat.template.json | 27 ++++++++++-- 3 files changed, 99 insertions(+), 10 deletions(-) diff --git a/metricbeat/docs/fields.asciidoc b/metricbeat/docs/fields.asciidoc index 0e5b5256c5fd..b3e10b94c4ba 100644 --- a/metricbeat/docs/fields.asciidoc +++ b/metricbeat/docs/fields.asciidoc @@ -1395,16 +1395,62 @@ Healthcheck status code [float] == image Fields -image +Docker image metrics. [float] -=== docker.image.example +== id Fields + +The image layers ID. + + + +[float] +=== docker.image.id.current + +type: keyword + +Unique image ID given upon its creation. + + +[float] +=== docker.image.id.parent type: keyword -Example field +ID of the image, if it exists, from which the current image directly descends. + + +[float] +=== docker.image.created + +type: date + +Date and time when the image was created. + + +[float] +== size Fields + +Image size layers. + + + +[float] +=== docker.image.size.virtual + +type: long + +Size of the image. + + +[float] +=== docker.image.size.regular + +type: long + +Total size of the all cached images associated to the current image. [float] diff --git a/metricbeat/metricbeat.template-es2x.json b/metricbeat/metricbeat.template-es2x.json index 15dcb13b787b..c91c65f39e65 100644 --- a/metricbeat/metricbeat.template-es2x.json +++ b/metricbeat/metricbeat.template-es2x.json @@ -812,10 +812,32 @@ }, "image": { "properties": { - "example": { - "ignore_above": 1024, - "index": "not_analyzed", - "type": "string" + "created": { + "type": "date" + }, + "id": { + "properties": { + "current": { + "ignore_above": 1024, + "index": "not_analyzed", + "type": "string" + }, + "parent": { + "ignore_above": 1024, + "index": "not_analyzed", + "type": "string" + } + } + }, + "size": { + "properties": { + "regular": { + "type": "long" + }, + "virtual": { + "type": "long" + } + } } } }, diff --git a/metricbeat/metricbeat.template.json b/metricbeat/metricbeat.template.json index 7520488bd284..adefb6a0f061 100644 --- a/metricbeat/metricbeat.template.json +++ b/metricbeat/metricbeat.template.json @@ -808,9 +808,30 @@ }, "image": { "properties": { - "example": { - "ignore_above": 1024, - "type": "keyword" + "created": { + "type": "date" + }, + "id": { + "properties": { + "current": { + "ignore_above": 1024, + "type": "keyword" + }, + "parent": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "size": { + "properties": { + "regular": { + "type": "long" + }, + "virtual": { + "type": "long" + } + } } } }, From 08cc8034f6e63e4e21cc3667a67b9cd2e1e4c0ea Mon Sep 17 00:00:00 2001 From: Douae Jeouit Date: Wed, 1 Feb 2017 10:15:19 +0100 Subject: [PATCH 09/14] update test_docker.py --- metricbeat/tests/system/test_docker.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/metricbeat/tests/system/test_docker.py b/metricbeat/tests/system/test_docker.py index 193ccbef8c3e..eab81f6e153e 100644 --- a/metricbeat/tests/system/test_docker.py +++ b/metricbeat/tests/system/test_docker.py @@ -214,7 +214,9 @@ def test_image_fields(self): output = self.read_output_json() evt = output[0] - evt = self.remove_labels(evt) + if 'labels' in evt["docker"]["image"] | 'tags' in evt["docker"]["image"]: + del evt["docker"]["image"]["labels"] + del evt["docker"]["image"]["tags"] self.assert_fields_are_documented(evt) def remove_labels(self, evt): From f78fc9e8cc9162042d9649c8edc5c312113425c3 Mon Sep 17 00:00:00 2001 From: Douae Jeouit Date: Wed, 1 Feb 2017 14:24:05 +0100 Subject: [PATCH 10/14] replace ID by identifier in feilds.yml --- metricbeat/module/docker/image/_meta/fields.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/metricbeat/module/docker/image/_meta/fields.yml b/metricbeat/module/docker/image/_meta/fields.yml index 709f78f2df90..c4bb774a38fe 100644 --- a/metricbeat/module/docker/image/_meta/fields.yml +++ b/metricbeat/module/docker/image/_meta/fields.yml @@ -6,16 +6,16 @@ - name: id type: group description: > - The image layers ID. + The image layers identifier. fields: - name: current type: keyword description: > - Unique image ID given upon its creation. + Unique image identifier given upon its creation. - name: parent type: keyword description: > - ID of the image, if it exists, from which the current image directly descends. + Identifier of the image, if it exists, from which the current image directly descends. - name: created type: date description: > From 1ef8765b5f8e0d8a5bec6899614786a04a519fba Mon Sep 17 00:00:00 2001 From: Douae Jeouit Date: Wed, 1 Feb 2017 16:11:47 +0100 Subject: [PATCH 11/14] test labels fields --- metricbeat/tests/system/test_docker.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/metricbeat/tests/system/test_docker.py b/metricbeat/tests/system/test_docker.py index eab81f6e153e..a80713f3b836 100644 --- a/metricbeat/tests/system/test_docker.py +++ b/metricbeat/tests/system/test_docker.py @@ -214,9 +214,8 @@ def test_image_fields(self): output = self.read_output_json() evt = output[0] - if 'labels' in evt["docker"]["image"] | 'tags' in evt["docker"]["image"]: + if 'labels' in evt["docker"]["image"] : del evt["docker"]["image"]["labels"] - del evt["docker"]["image"]["tags"] self.assert_fields_are_documented(evt) def remove_labels(self, evt): From ff9ab7aaba16c74f5a16f321fe3e0a0d7f4e943a Mon Sep 17 00:00:00 2001 From: Douae Jeouit Date: Wed, 1 Feb 2017 16:12:58 +0100 Subject: [PATCH 12/14] replace ID by identifier --- metricbeat/docs/fields.asciidoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/metricbeat/docs/fields.asciidoc b/metricbeat/docs/fields.asciidoc index b3e10b94c4ba..404edb2f77f2 100644 --- a/metricbeat/docs/fields.asciidoc +++ b/metricbeat/docs/fields.asciidoc @@ -1402,7 +1402,7 @@ Docker image metrics. [float] == id Fields -The image layers ID. +The image layers identifier. @@ -1411,7 +1411,7 @@ The image layers ID. type: keyword -Unique image ID given upon its creation. +Unique image identifier given upon its creation. [float] @@ -1419,7 +1419,7 @@ Unique image ID given upon its creation. type: keyword -ID of the image, if it exists, from which the current image directly descends. +Identifier of the image, if it exists, from which the current image directly descends. [float] From 443e86c6c48a69653b68953f66d12e81b37d2d5f Mon Sep 17 00:00:00 2001 From: Douae Jeouit Date: Thu, 2 Feb 2017 09:55:19 +0100 Subject: [PATCH 13/14] Delete the "tags" key from test_docker.py because it is not documented in fields.yml. TODO : How to document list ? --- metricbeat/tests/system/test_docker.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/metricbeat/tests/system/test_docker.py b/metricbeat/tests/system/test_docker.py index a80713f3b836..e9acbd2e7dad 100644 --- a/metricbeat/tests/system/test_docker.py +++ b/metricbeat/tests/system/test_docker.py @@ -214,8 +214,10 @@ def test_image_fields(self): output = self.read_output_json() evt = output[0] - if 'labels' in evt["docker"]["image"] : - del evt["docker"]["image"]["labels"] + evt = self.remove_labels(evt) + + if 'tags' in evt["docker"]["image"] : + del evt["docker"]["image"]["tags"] self.assert_fields_are_documented(evt) def remove_labels(self, evt): From db79c1045400ccb22cc353b904ec4f15430d37bb Mon Sep 17 00:00:00 2001 From: Douae Jeouit Date: Fri, 3 Feb 2017 09:33:56 +0100 Subject: [PATCH 14/14] Remove both tags and labels from test image fields --- metricbeat/tests/system/test_docker.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/metricbeat/tests/system/test_docker.py b/metricbeat/tests/system/test_docker.py index e9acbd2e7dad..3b60e814ce49 100644 --- a/metricbeat/tests/system/test_docker.py +++ b/metricbeat/tests/system/test_docker.py @@ -214,10 +214,12 @@ def test_image_fields(self): output = self.read_output_json() evt = output[0] - evt = self.remove_labels(evt) - if 'tags' in evt["docker"]["image"] : del evt["docker"]["image"]["tags"] + + if 'labels' in evt["docker"]["image"] : + del evt["docker"]["image"]["labels"] + self.assert_fields_are_documented(evt) def remove_labels(self, evt):