diff --git a/libbeat/autodiscover/providers/kubernetes/pod.go b/libbeat/autodiscover/providers/kubernetes/pod.go index d4ecd937662..71c026bdf01 100644 --- a/libbeat/autodiscover/providers/kubernetes/pod.go +++ b/libbeat/autodiscover/providers/kubernetes/pod.go @@ -349,15 +349,15 @@ func (p *pod) emitEvents(pod *kubernetes.Pod, flag string, containers []kubernet // so it works also on `stop` if containers have been already deleted. eventID := fmt.Sprintf("%s.%s", pod.GetObjectMeta().GetUID(), c.Name) - meta := p.metagen.Generate( - pod, - metadata.WithFields("container.name", c.Name), - metadata.WithFields("container.image", c.Image), - ) + meta := p.metagen.Generate(pod) cmeta := common.MapStr{ "id": cid, "runtime": runtimes[c.Name], + "image": common.MapStr{ + "name": c.Image, + }, + "name": c.Name, } // Information that can be used in discovering a workload diff --git a/libbeat/autodiscover/providers/kubernetes/pod_test.go b/libbeat/autodiscover/providers/kubernetes/pod_test.go index 69b0d6c94f0..8940b731cee 100644 --- a/libbeat/autodiscover/providers/kubernetes/pod_test.go +++ b/libbeat/autodiscover/providers/kubernetes/pod_test.go @@ -452,14 +452,12 @@ func TestEmitEvent(t *testing.T) { }, "node": common.MapStr{ "name": "node", }, - "container": common.MapStr{ - "name": "filebeat", - "image": "elastic/filebeat:6.3.0", - }, }, "container": common.MapStr{ + "image": common.MapStr{"name": "elastic/filebeat:6.3.0"}, "id": "foobar", "runtime": "docker", + "name": "filebeat", }, }, "config": []*common.Config{}, @@ -576,14 +574,12 @@ func TestEmitEvent(t *testing.T) { }, "node": common.MapStr{ "name": "node", }, - "container": common.MapStr{ - "name": "filebeat", - "image": "elastic/filebeat:6.3.0", - }, }, "container": common.MapStr{ + "image": common.MapStr{"name": "elastic/filebeat:6.3.0"}, "runtime": "docker", "id": "foobar", + "name": "filebeat", }, }, "config": []*common.Config{}, @@ -620,14 +616,12 @@ func TestEmitEvent(t *testing.T) { }, "node": common.MapStr{ "name": "node", }, - "container": common.MapStr{ - "name": "filebeat", - "image": "elastic/filebeat:6.3.0", - }, }, "container": common.MapStr{ + "image": common.MapStr{"name": "elastic/filebeat:6.3.0"}, "id": "foobar", "runtime": "docker", + "name": "filebeat", }, }, "config": []*common.Config{}, @@ -790,14 +784,12 @@ func TestEmitEvent(t *testing.T) { }, "node": common.MapStr{ "name": "node", }, - "container": common.MapStr{ - "name": "filebeat", - "image": "elastic/filebeat:6.3.0", - }, }, "container": common.MapStr{ + "image": common.MapStr{"name": "elastic/filebeat:6.3.0"}, "runtime": "", "id": "", + "name": "filebeat", }, }, "config": []*common.Config{}, @@ -891,10 +883,6 @@ func TestEmitEvent(t *testing.T) { "meta": common.MapStr{ "kubernetes": common.MapStr{ "namespace": "default", - "container": common.MapStr{ - "name": "filebeat", - "image": "elastic/filebeat:6.3.0", - }, "pod": common.MapStr{ "name": "filebeat", "uid": "005f3b90-4b9d-12f8-acf0-31020a840133", @@ -903,8 +891,10 @@ func TestEmitEvent(t *testing.T) { }, }, "container": common.MapStr{ + "image": common.MapStr{"name": "elastic/filebeat:6.3.0"}, "id": "", "runtime": "", + "name": "filebeat", }, }, "config": []*common.Config{}, @@ -998,10 +988,6 @@ func TestEmitEvent(t *testing.T) { "meta": common.MapStr{ "kubernetes": common.MapStr{ "namespace": "default", - "container": common.MapStr{ - "name": "filebeat", - "image": "elastic/filebeat:6.3.0", - }, "pod": common.MapStr{ "name": "filebeat", "uid": "005f3b90-4b9d-12f8-acf0-31020a840133", @@ -1010,8 +996,10 @@ func TestEmitEvent(t *testing.T) { }, }, "container": common.MapStr{ + "image": common.MapStr{"name": "elastic/filebeat:6.3.0"}, "runtime": "", "id": "", + "name": "filebeat", }, }, "config": []*common.Config{}, @@ -1115,14 +1103,12 @@ func TestEmitEvent(t *testing.T) { }, "node": common.MapStr{ "name": "node", }, - "container": common.MapStr{ - "name": "filebeat", - "image": "elastic/filebeat:6.3.0", - }, }, "container": common.MapStr{ + "image": common.MapStr{"name": "elastic/filebeat:6.3.0"}, "id": "foobar", "runtime": "docker", + "name": "filebeat", }, }, "config": []*common.Config{}, @@ -1228,14 +1214,12 @@ func TestEmitEvent(t *testing.T) { }, "node": common.MapStr{ "name": "node", }, - "container": common.MapStr{ - "name": "filebeat", - "image": "elastic/filebeat:6.3.0", - }, }, "container": common.MapStr{ + "image": common.MapStr{"name": "elastic/filebeat:6.3.0"}, "id": "foobar", "runtime": "docker", + "name": "filebeat", }, }, "config": []*common.Config{}, @@ -1373,14 +1357,12 @@ func TestEmitEvent(t *testing.T) { }, "node": common.MapStr{ "name": "node", }, - "container": common.MapStr{ - "name": "filebeat", - "image": "elastic/filebeat:6.3.0", - }, }, "container": common.MapStr{ + "image": common.MapStr{"name": "elastic/filebeat:6.3.0"}, "id": "foobar", "runtime": "docker", + "name": "filebeat", }, }, "config": []*common.Config{}, @@ -1418,14 +1400,12 @@ func TestEmitEvent(t *testing.T) { }, "node": common.MapStr{ "name": "node", }, - "container": common.MapStr{ - "name": "filebeat-init", - "image": "elastic/filebeat:6.3.0", - }, }, "container": common.MapStr{ + "image": common.MapStr{"name": "elastic/filebeat:6.3.0"}, "id": "foobar-init", "runtime": "docker", + "name": "filebeat-init", }, }, "config": []*common.Config{}, @@ -1463,14 +1443,12 @@ func TestEmitEvent(t *testing.T) { }, "node": common.MapStr{ "name": "node", }, - "container": common.MapStr{ - "name": "filebeat-ephemeral", - "image": "elastic/filebeat:6.3.0", - }, }, "container": common.MapStr{ + "image": common.MapStr{"name": "elastic/filebeat:6.3.0"}, "id": "foobar-ephemeral", "runtime": "docker", + "name": "filebeat-ephemeral", }, }, "config": []*common.Config{}, diff --git a/libbeat/processors/add_kubernetes_metadata/kubernetes.go b/libbeat/processors/add_kubernetes_metadata/kubernetes.go index eb431ff39ce..6a2bb27d7c4 100644 --- a/libbeat/processors/add_kubernetes_metadata/kubernetes.go +++ b/libbeat/processors/add_kubernetes_metadata/kubernetes.go @@ -257,10 +257,11 @@ func (k *kubernetesAnnotator) Run(event *beat.Event) (*beat.Event, error) { } metaClone := metadata.Clone() - // image and name will be added to ECS fields through alias type - // id and runtime need to be added explicitly - metaClone.Delete("container.name") - metaClone.Delete("container.image") + containerImage, err := metaClone.GetValue("container.image") + if err == nil { + metaClone.Delete("container.image") + metaClone.Put("container.image.name", containerImage) + } cmeta, err := metaClone.Clone().GetValue("container") if err == nil { event.Fields.DeepUpdate(common.MapStr{ @@ -269,9 +270,8 @@ func (k *kubernetesAnnotator) Run(event *beat.Event) (*beat.Event, error) { } kubeMeta := metadata.Clone() - // remove id and runtime from kubernetes meta (their place is under container meta) - kubeMeta.Delete("container.id") - kubeMeta.Delete("container.runtime") + // remove container meta from kubernetes.container.* + kubeMeta.Delete("container") event.Fields.DeepUpdate(common.MapStr{ "kubernetes": kubeMeta, }) diff --git a/metricbeat/module/kubernetes/state_container/_meta/data.json b/metricbeat/module/kubernetes/state_container/_meta/data.json index 3da3545013c..9b0838fdb3b 100644 --- a/metricbeat/module/kubernetes/state_container/_meta/data.json +++ b/metricbeat/module/kubernetes/state_container/_meta/data.json @@ -17,10 +17,8 @@ "request": { "nanocores": 200000000 } - }, - "image": "ubuntu:latest", + }, "id": "docker://5f8ce416d10ab0b28ce5c7d521de2264aa03ff4d001e1194076f6a02a330139f", - "name": "ubuntu", "status": { "ready": true, "restarts": 0, @@ -62,11 +60,15 @@ }, "container": { "runtime": "docker", - "id": "5f8ce416d10ab0b28ce5c7d521de2264aa03ff4d001e1194076f6a02a330139f" + "id": "5f8ce416d10ab0b28ce5c7d521de2264aa03ff4d001e1194076f6a02a330139f", + "image": { + "name": "ubuntu:latest" + }, + "name": "ubuntu" }, "event": { "dataset": "kubernetes.container", "module": "kubernetes", "duration": 33750820 } -} \ No newline at end of file +} diff --git a/metricbeat/module/kubernetes/state_container/_meta/test/ksm.v1.3.0.expected b/metricbeat/module/kubernetes/state_container/_meta/test/ksm.v1.3.0.expected index 4d11be7adba..153b9f4ea73 100644 --- a/metricbeat/module/kubernetes/state_container/_meta/test/ksm.v1.3.0.expected +++ b/metricbeat/module/kubernetes/state_container/_meta/test/ksm.v1.3.0.expected @@ -2,7 +2,11 @@ { "RootFields": { "container": { - "id": "4beb9aab887ca162c9cb3534c4826156636241052cd548153eaa2a170b6d102f", + "id": "c46bc2164edcb5972be6fc9174155e61179cb04314c4f6da5d25d3a76acadee6", + "image": { + "name": "k8s.gcr.io/kubernetes-dashboard-amd64:v1.8.1" + }, + "name": "kubernetes-dashboard", "runtime": "docker" } }, @@ -12,18 +16,11 @@ "name": "minikube" }, "pod": { - "name": "kube-controller-manager-minikube" + "name": "kubernetes-dashboard-77d8b98585-vqtzm" } }, "MetricSetFields": { - "cpu": { - "request": { - "cores": 0.2 - } - }, - "id": "docker://4beb9aab887ca162c9cb3534c4826156636241052cd548153eaa2a170b6d102f", - "image": "gcr.io/google_containers/kube-controller-manager-amd64:v1.9.7", - "name": "kube-controller-manager", + "id": "docker://c46bc2164edcb5972be6fc9174155e61179cb04314c4f6da5d25d3a76acadee6", "status": { "phase": "running", "ready": true, @@ -44,7 +41,11 @@ { "RootFields": { "container": { - "id": "c46bc2164edcb5972be6fc9174155e61179cb04314c4f6da5d25d3a76acadee6", + "id": "eadcbd54ba914dff6475ae64805887967cfb973aeb9b07364c94372658a71d11", + "image": { + "name": "gcr.io/google_containers/kube-scheduler-amd64:v1.9.7" + }, + "name": "kube-scheduler", "runtime": "docker" } }, @@ -54,13 +55,16 @@ "name": "minikube" }, "pod": { - "name": "kubernetes-dashboard-77d8b98585-vqtzm" + "name": "kube-scheduler-minikube" } }, "MetricSetFields": { - "id": "docker://c46bc2164edcb5972be6fc9174155e61179cb04314c4f6da5d25d3a76acadee6", - "image": "k8s.gcr.io/kubernetes-dashboard-amd64:v1.8.1", - "name": "kubernetes-dashboard", + "cpu": { + "request": { + "cores": 0.1 + } + }, + "id": "docker://eadcbd54ba914dff6475ae64805887967cfb973aeb9b07364c94372658a71d11", "status": { "phase": "running", "ready": true, @@ -81,7 +85,11 @@ { "RootFields": { "container": { - "id": "88951e0178ea5131fa3e2d7cafacb3a7e63700795dd6fa0d40ed2e4ac1f52f9c", + "id": "ab382dbe8f8265f88ee9fec7de142f778da4a5fd9fe0334e3bdb6fe851124c08", + "image": { + "name": "k8s.gcr.io/kube-addon-manager:v8.6" + }, + "name": "kube-addon-manager", "runtime": "docker" } }, @@ -91,29 +99,21 @@ "name": "minikube" }, "pod": { - "name": "kube-state-metrics-6479d88c5c-5b6cl" + "name": "kube-addon-manager-minikube" } }, "MetricSetFields": { "cpu": { - "limit": { - "cores": 0.101 - }, "request": { - "cores": 0.101 + "cores": 0.005 } }, - "id": "docker://88951e0178ea5131fa3e2d7cafacb3a7e63700795dd6fa0d40ed2e4ac1f52f9c", - "image": "quay.io/coreos/kube-state-metrics:v1.3.0", + "id": "docker://ab382dbe8f8265f88ee9fec7de142f778da4a5fd9fe0334e3bdb6fe851124c08", "memory": { - "limit": { - "bytes": 106954752 - }, "request": { - "bytes": 106954752 + "bytes": 52428800 } }, - "name": "kube-state-metrics", "status": { "phase": "running", "ready": true, @@ -134,7 +134,11 @@ { "RootFields": { "container": { - "id": "948c4ebd8ca4fdf352e7fbf7f5c5d381af7e615ced435dc42fde0c1d25851320", + "id": "aad0addd205dc72dc7abc8f9d02a1b429a2f2e1df3acc60431ca6b79746c093b", + "image": { + "name": "gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.7" + }, + "name": "sidecar", "runtime": "docker" } }, @@ -144,32 +148,25 @@ "name": "minikube" }, "pod": { - "name": "kube-state-metrics-6479d88c5c-5b6cl" + "name": "kube-dns-6f4fd4bdf-wlmht" } }, "MetricSetFields": { "cpu": { - "limit": { - "cores": 0.1 - }, "request": { - "cores": 0.1 + "cores": 0.01 } }, - "id": "docker://948c4ebd8ca4fdf352e7fbf7f5c5d381af7e615ced435dc42fde0c1d25851320", - "image": "k8s.gcr.io/addon-resizer:1.7", + "id": "docker://aad0addd205dc72dc7abc8f9d02a1b429a2f2e1df3acc60431ca6b79746c093b", "memory": { - "limit": { - "bytes": 31457280 - }, "request": { - "bytes": 31457280 + "bytes": 20971520 } }, - "name": "addon-resizer", "status": { "phase": "running", "ready": true, + "reason": "OOMKilled", "restarts": 0 } }, @@ -187,7 +184,11 @@ { "RootFields": { "container": { - "id": "1958e71d048065d38ce83dafda567c5fa9d0c1278cd7292d55b9f1d80b0a67f9", + "id": "4beb9aab887ca162c9cb3534c4826156636241052cd548153eaa2a170b6d102f", + "image": { + "name": "gcr.io/google_containers/kube-controller-manager-amd64:v1.9.7" + }, + "name": "kube-controller-manager", "runtime": "docker" } }, @@ -197,26 +198,16 @@ "name": "minikube" }, "pod": { - "name": "kube-dns-6f4fd4bdf-wlmht" + "name": "kube-controller-manager-minikube" } }, "MetricSetFields": { "cpu": { "request": { - "cores": 0.1 - } - }, - "id": "docker://1958e71d048065d38ce83dafda567c5fa9d0c1278cd7292d55b9f1d80b0a67f9", - "image": "gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.7", - "memory": { - "limit": { - "bytes": 178257920 - }, - "request": { - "bytes": 73400320 + "cores": 0.2 } }, - "name": "kubedns", + "id": "docker://4beb9aab887ca162c9cb3534c4826156636241052cd548153eaa2a170b6d102f", "status": { "phase": "running", "ready": true, @@ -237,7 +228,11 @@ { "RootFields": { "container": { - "id": "76c260259ddfd0267b5acb4e514465215ef1ebfa93a4057d592828772e6b39f5", + "id": "e9560bbace13ca19de4b3771023198e8568f6b5ed6af3a949f10a5b8137b5be9", + "image": { + "name": "gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.7" + }, + "name": "dnsmasq", "runtime": "docker" } }, @@ -247,13 +242,21 @@ "name": "minikube" }, "pod": { - "name": "kube-proxy-znhg6" + "name": "kube-dns-6f4fd4bdf-wlmht" } }, "MetricSetFields": { - "id": "docker://76c260259ddfd0267b5acb4e514465215ef1ebfa93a4057d592828772e6b39f5", - "image": "gcr.io/google_containers/kube-proxy-amd64:v1.9.7", - "name": "kube-proxy", + "cpu": { + "request": { + "cores": 0.15 + } + }, + "id": "docker://e9560bbace13ca19de4b3771023198e8568f6b5ed6af3a949f10a5b8137b5be9", + "memory": { + "request": { + "bytes": 20971520 + } + }, "status": { "phase": "running", "ready": true, @@ -274,7 +277,11 @@ { "RootFields": { "container": { - "id": "f4cc07b8e7ee5952738c69a0bff0c7b331c10af66faa541197684127d393b760", + "id": "76c260259ddfd0267b5acb4e514465215ef1ebfa93a4057d592828772e6b39f5", + "image": { + "name": "gcr.io/google_containers/kube-proxy-amd64:v1.9.7" + }, + "name": "kube-proxy", "runtime": "docker" } }, @@ -284,17 +291,14 @@ "name": "minikube" }, "pod": { - "name": "storage-provisioner" + "name": "kube-proxy-znhg6" } }, "MetricSetFields": { - "id": "docker://f4cc07b8e7ee5952738c69a0bff0c7b331c10af66faa541197684127d393b760", - "image": "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", - "name": "storage-provisioner", + "id": "docker://76c260259ddfd0267b5acb4e514465215ef1ebfa93a4057d592828772e6b39f5", "status": { "phase": "running", "ready": true, - "reason": "ImagePullBackOff", "restarts": 0 } }, @@ -313,6 +317,10 @@ "RootFields": { "container": { "id": "e9568dfef1dd249cabac4bf09e6bf4a239fe738ae20eba072b6516676fce4bf6", + "image": { + "name": "gcr.io/google_containers/kube-apiserver-amd64:v1.9.7" + }, + "name": "kube-apiserver", "runtime": "docker" } }, @@ -332,8 +340,6 @@ } }, "id": "docker://e9568dfef1dd249cabac4bf09e6bf4a239fe738ae20eba072b6516676fce4bf6", - "image": "gcr.io/google_containers/kube-apiserver-amd64:v1.9.7", - "name": "kube-apiserver", "status": { "phase": "running", "ready": true, @@ -354,7 +360,11 @@ { "RootFields": { "container": { - "id": "eadcbd54ba914dff6475ae64805887967cfb973aeb9b07364c94372658a71d11", + "id": "88951e0178ea5131fa3e2d7cafacb3a7e63700795dd6fa0d40ed2e4ac1f52f9c", + "image": { + "name": "quay.io/coreos/kube-state-metrics:v1.3.0" + }, + "name": "kube-state-metrics", "runtime": "docker" } }, @@ -364,18 +374,27 @@ "name": "minikube" }, "pod": { - "name": "kube-scheduler-minikube" + "name": "kube-state-metrics-6479d88c5c-5b6cl" } }, "MetricSetFields": { "cpu": { + "limit": { + "cores": 0.101 + }, "request": { - "cores": 0.1 + "cores": 0.101 + } + }, + "id": "docker://88951e0178ea5131fa3e2d7cafacb3a7e63700795dd6fa0d40ed2e4ac1f52f9c", + "memory": { + "limit": { + "bytes": 106954752 + }, + "request": { + "bytes": 106954752 } }, - "id": "docker://eadcbd54ba914dff6475ae64805887967cfb973aeb9b07364c94372658a71d11", - "image": "gcr.io/google_containers/kube-scheduler-amd64:v1.9.7", - "name": "kube-scheduler", "status": { "phase": "running", "ready": true, @@ -396,7 +415,11 @@ { "RootFields": { "container": { - "id": "6e96fd8a687409b2314dcc01f209bb0c813c2fb08b8f75ad1695e120d41e1a2a", + "id": "f4cc07b8e7ee5952738c69a0bff0c7b331c10af66faa541197684127d393b760", + "image": { + "name": "gcr.io/k8s-minikube/storage-provisioner:v1.8.1" + }, + "name": "storage-provisioner", "runtime": "docker" } }, @@ -406,16 +429,15 @@ "name": "minikube" }, "pod": { - "name": "etcd-minikube" + "name": "storage-provisioner" } }, "MetricSetFields": { - "id": "docker://6e96fd8a687409b2314dcc01f209bb0c813c2fb08b8f75ad1695e120d41e1a2a", - "image": "gcr.io/google_containers/etcd-amd64:3.1.11", - "name": "etcd", + "id": "docker://f4cc07b8e7ee5952738c69a0bff0c7b331c10af66faa541197684127d393b760", "status": { "phase": "running", "ready": true, + "reason": "ImagePullBackOff", "restarts": 0 } }, @@ -433,7 +455,11 @@ { "RootFields": { "container": { - "id": "ab382dbe8f8265f88ee9fec7de142f778da4a5fd9fe0334e3bdb6fe851124c08", + "id": "1958e71d048065d38ce83dafda567c5fa9d0c1278cd7292d55b9f1d80b0a67f9", + "image": { + "name": "gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.7" + }, + "name": "kubedns", "runtime": "docker" } }, @@ -443,23 +469,24 @@ "name": "minikube" }, "pod": { - "name": "kube-addon-manager-minikube" + "name": "kube-dns-6f4fd4bdf-wlmht" } }, "MetricSetFields": { "cpu": { "request": { - "cores": 0.005 + "cores": 0.1 } }, - "id": "docker://ab382dbe8f8265f88ee9fec7de142f778da4a5fd9fe0334e3bdb6fe851124c08", - "image": "k8s.gcr.io/kube-addon-manager:v8.6", + "id": "docker://1958e71d048065d38ce83dafda567c5fa9d0c1278cd7292d55b9f1d80b0a67f9", "memory": { + "limit": { + "bytes": 178257920 + }, "request": { - "bytes": 52428800 + "bytes": 73400320 } }, - "name": "kube-addon-manager", "status": { "phase": "running", "ready": true, @@ -480,7 +507,11 @@ { "RootFields": { "container": { - "id": "aad0addd205dc72dc7abc8f9d02a1b429a2f2e1df3acc60431ca6b79746c093b", + "id": "6e96fd8a687409b2314dcc01f209bb0c813c2fb08b8f75ad1695e120d41e1a2a", + "image": { + "name": "gcr.io/google_containers/etcd-amd64:3.1.11" + }, + "name": "etcd", "runtime": "docker" } }, @@ -490,27 +521,14 @@ "name": "minikube" }, "pod": { - "name": "kube-dns-6f4fd4bdf-wlmht" + "name": "etcd-minikube" } }, "MetricSetFields": { - "cpu": { - "request": { - "cores": 0.01 - } - }, - "id": "docker://aad0addd205dc72dc7abc8f9d02a1b429a2f2e1df3acc60431ca6b79746c093b", - "image": "gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.7", - "memory": { - "request": { - "bytes": 20971520 - } - }, - "name": "sidecar", + "id": "docker://6e96fd8a687409b2314dcc01f209bb0c813c2fb08b8f75ad1695e120d41e1a2a", "status": { "phase": "running", "ready": true, - "reason": "OOMKilled", "restarts": 0 } }, @@ -528,7 +546,11 @@ { "RootFields": { "container": { - "id": "e9560bbace13ca19de4b3771023198e8568f6b5ed6af3a949f10a5b8137b5be9", + "id": "948c4ebd8ca4fdf352e7fbf7f5c5d381af7e615ced435dc42fde0c1d25851320", + "image": { + "name": "k8s.gcr.io/addon-resizer:1.7" + }, + "name": "addon-resizer", "runtime": "docker" } }, @@ -538,23 +560,27 @@ "name": "minikube" }, "pod": { - "name": "kube-dns-6f4fd4bdf-wlmht" + "name": "kube-state-metrics-6479d88c5c-5b6cl" } }, "MetricSetFields": { "cpu": { + "limit": { + "cores": 0.1 + }, "request": { - "cores": 0.15 + "cores": 0.1 } }, - "id": "docker://e9560bbace13ca19de4b3771023198e8568f6b5ed6af3a949f10a5b8137b5be9", - "image": "gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.7", + "id": "docker://948c4ebd8ca4fdf352e7fbf7f5c5d381af7e615ced435dc42fde0c1d25851320", "memory": { + "limit": { + "bytes": 31457280 + }, "request": { - "bytes": 20971520 + "bytes": 31457280 } }, - "name": "dnsmasq", "status": { "phase": "running", "ready": true, diff --git a/metricbeat/module/kubernetes/state_container/_meta/test/ksm.v1.8.0.expected b/metricbeat/module/kubernetes/state_container/_meta/test/ksm.v1.8.0.expected index 613fb647357..927b23c27ea 100644 --- a/metricbeat/module/kubernetes/state_container/_meta/test/ksm.v1.8.0.expected +++ b/metricbeat/module/kubernetes/state_container/_meta/test/ksm.v1.8.0.expected @@ -3,6 +3,10 @@ "RootFields": { "container": { "id": "c152296116c064db311061cf6c39cff2de8d66339c954505cb68816464cf4a03", + "image": { + "name": "k8s.gcr.io/kube-proxy:v1.16.2" + }, + "name": "kube-proxy", "runtime": "docker" } }, @@ -17,8 +21,6 @@ }, "MetricSetFields": { "id": "docker://c152296116c064db311061cf6c39cff2de8d66339c954505cb68816464cf4a03", - "image": "k8s.gcr.io/kube-proxy:v1.16.2", - "name": "kube-proxy", "status": { "phase": "running", "ready": true, @@ -39,7 +41,11 @@ { "RootFields": { "container": { - "id": "cdaefb4df2f2add498f884fdc717a6ca8d2681c1636934747de600e6427e0c0d", + "id": "f13c53a3ed0f3626b33b3c588d6913257320f65714eff28f25ead8f7663dc93b", + "image": { + "name": "k8s.gcr.io/kube-addon-manager:v9.0.2" + }, + "name": "kube-addon-manager", "runtime": "docker" } }, @@ -49,18 +55,21 @@ "name": "minikube" }, "pod": { - "name": "kube-apiserver-minikube" + "name": "kube-addon-manager-minikube" } }, "MetricSetFields": { "cpu": { "request": { - "cores": 0.25 + "cores": 0.005 + } + }, + "id": "docker://f13c53a3ed0f3626b33b3c588d6913257320f65714eff28f25ead8f7663dc93b", + "memory": { + "request": { + "bytes": 52428800 } }, - "id": "docker://cdaefb4df2f2add498f884fdc717a6ca8d2681c1636934747de600e6427e0c0d", - "image": "k8s.gcr.io/kube-apiserver:v1.16.2", - "name": "kube-apiserver", "status": { "phase": "running", "ready": true, @@ -81,23 +90,25 @@ { "RootFields": { "container": { - "id": "2e0519a3fcd62acea8f4253b994ce53356d89171c0eb0920a13fe58b637d8cdb", + "id": "a4cec783af3614b137f4b449eebf3ac61eaf0a8661cb2f4847741be5a24de0bf", + "image": { + "name": "k8s.gcr.io/nginx-slim:0.8" + }, + "name": "nginx", "runtime": "docker" } }, "ModuleFields": { - "namespace": "kube-system", + "namespace": "default", "node": { "name": "minikube" }, "pod": { - "name": "kube-state-metrics-898d4db8d-dqmtg" + "name": "web-0" } }, "MetricSetFields": { - "id": "docker://2e0519a3fcd62acea8f4253b994ce53356d89171c0eb0920a13fe58b637d8cdb", - "image": "quay.io/coreos/kube-state-metrics:v1.8.0", - "name": "kube-state-metrics", + "id": "docker://a4cec783af3614b137f4b449eebf3ac61eaf0a8661cb2f4847741be5a24de0bf", "status": { "phase": "running", "ready": true, @@ -118,7 +129,11 @@ { "RootFields": { "container": { - "id": "15ada7864628d1c8007c01420e5887a501590d3bc9c25628a4770172ad615112", + "id": "842fbd62a0ab71b9ed9139edce3db502e9d81e545b9646daa3cde09f9986ab06", + "image": { + "name": "k8s.gcr.io/etcd:3.3.15-0" + }, + "name": "etcd", "runtime": "docker" } }, @@ -128,26 +143,11 @@ "name": "minikube" }, "pod": { - "name": "coredns-5644d7b6d9-k6wsp" + "name": "etcd-minikube" } }, "MetricSetFields": { - "cpu": { - "request": { - "cores": 0.1 - } - }, - "id": "docker://15ada7864628d1c8007c01420e5887a501590d3bc9c25628a4770172ad615112", - "image": "k8s.gcr.io/coredns:1.6.2", - "memory": { - "limit": { - "bytes": 178257920 - }, - "request": { - "bytes": 73400320 - } - }, - "name": "coredns", + "id": "docker://842fbd62a0ab71b9ed9139edce3db502e9d81e545b9646daa3cde09f9986ab06", "status": { "phase": "running", "ready": true, @@ -168,7 +168,11 @@ { "RootFields": { "container": { - "id": "669cc415d86b872450deaada60c73cca387ca23a7b0f21c5b146467b95cf1f76", + "id": "30216f9823ca7d3454987075dd7256b665b14b2333c9a6762b127b6378516609", + "image": { + "name": "busybox:latest" + }, + "name": "hello", "runtime": "docker" } }, @@ -178,16 +182,15 @@ "name": "minikube" }, "pod": { - "name": "web-1" + "name": "hello-1578512100-vr7wj" } }, "MetricSetFields": { - "id": "docker://669cc415d86b872450deaada60c73cca387ca23a7b0f21c5b146467b95cf1f76", - "image": "k8s.gcr.io/nginx-slim:0.8", - "name": "nginx", + "id": "docker://30216f9823ca7d3454987075dd7256b665b14b2333c9a6762b127b6378516609", "status": { - "phase": "running", - "ready": true, + "phase": "terminated", + "ready": false, + "reason": "Completed", "restarts": 0 } }, @@ -205,7 +208,11 @@ { "RootFields": { "container": { - "id": "f8fe5be1dbb1931d702c89235c79965730cbcced7b0ced9895f6c54c1ae8e5c3", + "id": "0ea0cef8a79c7643474a736e5da14c254d9411d87167028fa07c96d09748c83a", + "image": { + "name": "k8s.gcr.io/kube-scheduler:v1.16.2" + }, + "name": "kube-scheduler", "runtime": "docker" } }, @@ -215,7 +222,7 @@ "name": "minikube" }, "pod": { - "name": "coredns-5644d7b6d9-fhwjd" + "name": "kube-scheduler-minikube" } }, "MetricSetFields": { @@ -224,17 +231,7 @@ "cores": 0.1 } }, - "id": "docker://f8fe5be1dbb1931d702c89235c79965730cbcced7b0ced9895f6c54c1ae8e5c3", - "image": "k8s.gcr.io/coredns:1.6.2", - "memory": { - "limit": { - "bytes": 178257920 - }, - "request": { - "bytes": 73400320 - } - }, - "name": "coredns", + "id": "docker://0ea0cef8a79c7643474a736e5da14c254d9411d87167028fa07c96d09748c83a", "status": { "phase": "running", "ready": true, @@ -255,7 +252,11 @@ { "RootFields": { "container": { - "id": "f13c53a3ed0f3626b33b3c588d6913257320f65714eff28f25ead8f7663dc93b", + "id": "2e0519a3fcd62acea8f4253b994ce53356d89171c0eb0920a13fe58b637d8cdb", + "image": { + "name": "quay.io/coreos/kube-state-metrics:v1.8.0" + }, + "name": "kube-state-metrics", "runtime": "docker" } }, @@ -265,23 +266,11 @@ "name": "minikube" }, "pod": { - "name": "kube-addon-manager-minikube" + "name": "kube-state-metrics-898d4db8d-dqmtg" } }, "MetricSetFields": { - "cpu": { - "request": { - "cores": 0.005 - } - }, - "id": "docker://f13c53a3ed0f3626b33b3c588d6913257320f65714eff28f25ead8f7663dc93b", - "image": "k8s.gcr.io/kube-addon-manager:v9.0.2", - "memory": { - "request": { - "bytes": 52428800 - } - }, - "name": "kube-addon-manager", + "id": "docker://2e0519a3fcd62acea8f4253b994ce53356d89171c0eb0920a13fe58b637d8cdb", "status": { "phase": "running", "ready": true, @@ -302,7 +291,11 @@ { "RootFields": { "container": { - "id": "842fbd62a0ab71b9ed9139edce3db502e9d81e545b9646daa3cde09f9986ab06", + "id": "f8fe5be1dbb1931d702c89235c79965730cbcced7b0ced9895f6c54c1ae8e5c3", + "image": { + "name": "k8s.gcr.io/coredns:1.6.2" + }, + "name": "coredns", "runtime": "docker" } }, @@ -312,13 +305,24 @@ "name": "minikube" }, "pod": { - "name": "etcd-minikube" + "name": "coredns-5644d7b6d9-fhwjd" } }, "MetricSetFields": { - "id": "docker://842fbd62a0ab71b9ed9139edce3db502e9d81e545b9646daa3cde09f9986ab06", - "image": "k8s.gcr.io/etcd:3.3.15-0", - "name": "etcd", + "cpu": { + "request": { + "cores": 0.1 + } + }, + "id": "docker://f8fe5be1dbb1931d702c89235c79965730cbcced7b0ced9895f6c54c1ae8e5c3", + "memory": { + "limit": { + "bytes": 178257920 + }, + "request": { + "bytes": 73400320 + } + }, "status": { "phase": "running", "ready": true, @@ -339,28 +343,25 @@ { "RootFields": { "container": { - "id": "465ebffafd7fc238a2fa2e764255efcbff88d5513f4c68f57d70932985428d12", + "id": "669cc415d86b872450deaada60c73cca387ca23a7b0f21c5b146467b95cf1f76", + "image": { + "name": "k8s.gcr.io/nginx-slim:0.8" + }, + "name": "nginx", "runtime": "docker" } }, "ModuleFields": { - "namespace": "kube-system", + "namespace": "default", "node": { "name": "minikube" }, "pod": { - "name": "kube-controller-manager-minikube" + "name": "web-1" } }, "MetricSetFields": { - "cpu": { - "request": { - "cores": 0.2 - } - }, - "id": "docker://465ebffafd7fc238a2fa2e764255efcbff88d5513f4c68f57d70932985428d12", - "image": "k8s.gcr.io/kube-controller-manager:v1.16.2", - "name": "kube-controller-manager", + "id": "docker://669cc415d86b872450deaada60c73cca387ca23a7b0f21c5b146467b95cf1f76", "status": { "phase": "running", "ready": true, @@ -381,23 +382,25 @@ { "RootFields": { "container": { - "id": "a4cec783af3614b137f4b449eebf3ac61eaf0a8661cb2f4847741be5a24de0bf", + "id": "e0b05fcb32abf937c395942e0234b5dfc834206149bbb95afa585c51693650f3", + "image": { + "name": "gcr.io/k8s-minikube/storage-provisioner:v1.8.1" + }, + "name": "storage-provisioner", "runtime": "docker" } }, "ModuleFields": { - "namespace": "default", + "namespace": "kube-system", "node": { "name": "minikube" }, "pod": { - "name": "web-0" + "name": "storage-provisioner" } }, "MetricSetFields": { - "id": "docker://a4cec783af3614b137f4b449eebf3ac61eaf0a8661cb2f4847741be5a24de0bf", - "image": "k8s.gcr.io/nginx-slim:0.8", - "name": "nginx", + "id": "docker://e0b05fcb32abf937c395942e0234b5dfc834206149bbb95afa585c51693650f3", "status": { "phase": "running", "ready": true, @@ -418,7 +421,11 @@ { "RootFields": { "container": { - "id": "e0b05fcb32abf937c395942e0234b5dfc834206149bbb95afa585c51693650f3", + "id": "15ada7864628d1c8007c01420e5887a501590d3bc9c25628a4770172ad615112", + "image": { + "name": "k8s.gcr.io/coredns:1.6.2" + }, + "name": "coredns", "runtime": "docker" } }, @@ -428,13 +435,24 @@ "name": "minikube" }, "pod": { - "name": "storage-provisioner" + "name": "coredns-5644d7b6d9-k6wsp" } }, "MetricSetFields": { - "id": "docker://e0b05fcb32abf937c395942e0234b5dfc834206149bbb95afa585c51693650f3", - "image": "gcr.io/k8s-minikube/storage-provisioner:v1.8.1", - "name": "storage-provisioner", + "cpu": { + "request": { + "cores": 0.1 + } + }, + "id": "docker://15ada7864628d1c8007c01420e5887a501590d3bc9c25628a4770172ad615112", + "memory": { + "limit": { + "bytes": 178257920 + }, + "request": { + "bytes": 73400320 + } + }, "status": { "phase": "running", "ready": true, @@ -455,27 +473,33 @@ { "RootFields": { "container": { - "id": "30216f9823ca7d3454987075dd7256b665b14b2333c9a6762b127b6378516609", + "id": "cdaefb4df2f2add498f884fdc717a6ca8d2681c1636934747de600e6427e0c0d", + "image": { + "name": "k8s.gcr.io/kube-apiserver:v1.16.2" + }, + "name": "kube-apiserver", "runtime": "docker" } }, "ModuleFields": { - "namespace": "default", + "namespace": "kube-system", "node": { "name": "minikube" }, "pod": { - "name": "hello-1578512100-vr7wj" + "name": "kube-apiserver-minikube" } }, "MetricSetFields": { - "id": "docker://30216f9823ca7d3454987075dd7256b665b14b2333c9a6762b127b6378516609", - "image": "busybox:latest", - "name": "hello", + "cpu": { + "request": { + "cores": 0.25 + } + }, + "id": "docker://cdaefb4df2f2add498f884fdc717a6ca8d2681c1636934747de600e6427e0c0d", "status": { - "phase": "terminated", - "ready": false, - "reason": "Completed", + "phase": "running", + "ready": true, "restarts": 0 } }, @@ -493,7 +517,11 @@ { "RootFields": { "container": { - "id": "0ea0cef8a79c7643474a736e5da14c254d9411d87167028fa07c96d09748c83a", + "id": "465ebffafd7fc238a2fa2e764255efcbff88d5513f4c68f57d70932985428d12", + "image": { + "name": "k8s.gcr.io/kube-controller-manager:v1.16.2" + }, + "name": "kube-controller-manager", "runtime": "docker" } }, @@ -503,18 +531,16 @@ "name": "minikube" }, "pod": { - "name": "kube-scheduler-minikube" + "name": "kube-controller-manager-minikube" } }, "MetricSetFields": { "cpu": { "request": { - "cores": 0.1 + "cores": 0.2 } }, - "id": "docker://0ea0cef8a79c7643474a736e5da14c254d9411d87167028fa07c96d09748c83a", - "image": "k8s.gcr.io/kube-scheduler:v1.16.2", - "name": "kube-scheduler", + "id": "docker://465ebffafd7fc238a2fa2e764255efcbff88d5513f4c68f57d70932985428d12", "status": { "phase": "running", "ready": true, diff --git a/metricbeat/module/kubernetes/state_container/_meta/testdata/ksm-v1_3_0.plain-expected.json b/metricbeat/module/kubernetes/state_container/_meta/testdata/ksm-v1_3_0.plain-expected.json index f8278f2106b..b14b32898e9 100644 --- a/metricbeat/module/kubernetes/state_container/_meta/testdata/ksm-v1_3_0.plain-expected.json +++ b/metricbeat/module/kubernetes/state_container/_meta/testdata/ksm-v1_3_0.plain-expected.json @@ -1,5 +1,13 @@ [ { + "container": { + "id": "469f5d2b7854eb52e5d13dc0cd3e664c1b682b157aabaf596ffe4984f1516902", + "image": { + "name": "gcr.io/kubernetes-helm/tiller:v2.3.1" + }, + "name": "tiller", + "runtime": "docker" + }, "event": { "dataset": "kubernetes.container", "duration": 115000, @@ -7,27 +15,19 @@ }, "kubernetes": { "container": { - "cpu": { - "limit": { - "cores": 0.2 - }, - "request": { - "cores": 0.1 - } - }, - "memory": { - "limit": { - "bytes": 52428800 - }, - "request": { - "bytes": 31457280 - } - }, - "name": "kube-state-metrics" + "id": "docker://469f5d2b7854eb52e5d13dc0cd3e664c1b682b157aabaf596ffe4984f1516902", + "status": { + "phase": "running", + "ready": true, + "restarts": 1 + } }, "namespace": "kube-system", + "node": { + "name": "minikube" + }, "pod": { - "name": "kube-state-metrics-1303537707-mnzbp" + "name": "tiller-deploy-3067024529-9lpmb" } }, "metricset": { @@ -41,7 +41,11 @@ }, { "container": { - "id": "4fa227874ee68536bf902394fb662f07b99099798ca9cd5c1506b79075acc065", + "id": "fa3d83f648de42492b38fa3e8501d109376f391c50f2bd210c895c8477ae4b62", + "image": { + "name": "gcr.io/google_containers/kubedns-amd64:1.9" + }, + "name": "kubedns", "runtime": "docker" }, "event": { @@ -56,26 +60,27 @@ "cores": 0.1 } }, - "id": "docker://4fa227874ee68536bf902394fb662f07b99099798ca9cd5c1506b79075acc065", - "image": "bitnami/redis:3.2.8-r2", + "id": "docker://fa3d83f648de42492b38fa3e8501d109376f391c50f2bd210c895c8477ae4b62", "memory": { + "limit": { + "bytes": 178257920 + }, "request": { - "bytes": 268435456 + "bytes": 73400320 } }, - "name": "jumpy-owl-redis", "status": { - "phase": "waiting", - "ready": false, - "restarts": 270 + "phase": "running", + "ready": true, + "restarts": 2 } }, - "namespace": "default", + "namespace": "kube-system", "node": { "name": "minikube" }, "pod": { - "name": "jumpy-owl-redis-3481028193-s78x9" + "name": "kube-dns-v20-5g5cb" } }, "metricset": { @@ -89,7 +94,11 @@ }, { "container": { - "id": "9a4c9462cd078d7be4f0a9b94bcfeb69d5fdd76bff67142df3f58367ac7e8d61", + "id": "fa3d83f648de42492b38fa3e8501d109376f391c50f2bd210c895c8477ae4b62-test", + "image": { + "name": "gcr.io/google_containers/kubedns-amd64:1.9-test" + }, + "name": "kubedns", "runtime": "docker" }, "event": { @@ -99,21 +108,32 @@ }, "kubernetes": { "container": { - "id": "docker://9a4c9462cd078d7be4f0a9b94bcfeb69d5fdd76bff67142df3f58367ac7e8d61", - "image": "gcr.io/google_containers/kube-dnsmasq-amd64:1.4", - "name": "dnsmasq", + "cpu": { + "request": { + "cores": 0.2 + } + }, + "id": "docker://fa3d83f648de42492b38fa3e8501d109376f391c50f2bd210c895c8477ae4b62-test", + "memory": { + "limit": { + "bytes": 278257920 + }, + "request": { + "bytes": 83400320 + } + }, "status": { - "phase": "running", - "ready": true, - "restarts": 2 + "phase": "terminated", + "ready": false, + "restarts": 3 } }, - "namespace": "kube-system", + "namespace": "test", "node": { - "name": "minikube" + "name": "minikube-test" }, "pod": { - "name": "kube-dns-v20-5g5cb" + "name": "kube-dns-v20-5g5cb-test" } }, "metricset": { @@ -127,7 +147,11 @@ }, { "container": { - "id": "973cbe45982c5126a5caf8c58d964c0ab1d5bb2c165ccc59715fcc1ebd58ab3d", + "id": "91fdd43f6b1b4c3dd133cfca53e0b1210bc557c2ae56006026b5ccdb5f52826f", + "image": { + "name": "gcr.io/google-containers/kube-addon-manager:v6.3" + }, + "name": "kube-addon-manager", "runtime": "docker" }, "event": { @@ -138,28 +162,20 @@ "kubernetes": { "container": { "cpu": { - "limit": { - "cores": 0.2 - }, "request": { - "cores": 0.1 + "cores": 0.005 } }, - "id": "docker://973cbe45982c5126a5caf8c58d964c0ab1d5bb2c165ccc59715fcc1ebd58ab3d", - "image": "gcr.io/google_containers/kube-state-metrics:v0.4.1", + "id": "docker://91fdd43f6b1b4c3dd133cfca53e0b1210bc557c2ae56006026b5ccdb5f52826f", "memory": { - "limit": { - "bytes": 52428800 - }, "request": { - "bytes": 31457280 + "bytes": 52428800 } }, - "name": "kube-state-metrics", "status": { "phase": "running", "ready": true, - "restarts": 1 + "restarts": 2 } }, "namespace": "kube-system", @@ -167,7 +183,7 @@ "name": "minikube" }, "pod": { - "name": "kube-state-metrics-1303537707-7ncd1" + "name": "kube-addon-manager-minikube" } }, "metricset": { @@ -181,7 +197,11 @@ }, { "container": { - "id": "fa3d83f648de42492b38fa3e8501d109376f391c50f2bd210c895c8477ae4b62", + "id": "9a4c9462cd078d7be4f0a9b94bcfeb69d5fdd76bff67142df3f58367ac7e8d61", + "image": { + "name": "gcr.io/google_containers/kube-dnsmasq-amd64:1.4" + }, + "name": "dnsmasq", "runtime": "docker" }, "event": { @@ -191,22 +211,7 @@ }, "kubernetes": { "container": { - "cpu": { - "request": { - "cores": 0.1 - } - }, - "id": "docker://fa3d83f648de42492b38fa3e8501d109376f391c50f2bd210c895c8477ae4b62", - "image": "gcr.io/google_containers/kubedns-amd64:1.9", - "memory": { - "limit": { - "bytes": 178257920 - }, - "request": { - "bytes": 73400320 - } - }, - "name": "kubedns", + "id": "docker://9a4c9462cd078d7be4f0a9b94bcfeb69d5fdd76bff67142df3f58367ac7e8d61", "status": { "phase": "running", "ready": true, @@ -233,6 +238,10 @@ { "container": { "id": "e2ee1c2c7b8d4e5fd8c834b83cba8377d6b0e39da18157688ccc1a06b7c53117", + "image": { + "name": "jenkinsci/jenkins:2.46.1" + }, + "name": "wise-lynx-jenkins", "runtime": "docker" }, "event": { @@ -248,13 +257,11 @@ } }, "id": "docker://e2ee1c2c7b8d4e5fd8c834b83cba8377d6b0e39da18157688ccc1a06b7c53117", - "image": "jenkinsci/jenkins:2.46.1", "memory": { "request": { "bytes": 268435456 } }, - "name": "wise-lynx-jenkins", "status": { "phase": "running", "ready": true, @@ -280,8 +287,7 @@ }, { "container": { - "id": "91fdd43f6b1b4c3dd133cfca53e0b1210bc557c2ae56006026b5ccdb5f52826f", - "runtime": "docker" + "name": "kube-state-metrics" }, "event": { "dataset": "kubernetes.container", @@ -291,30 +297,25 @@ "kubernetes": { "container": { "cpu": { + "limit": { + "cores": 0.2 + }, "request": { - "cores": 0.005 + "cores": 0.1 } }, - "id": "docker://91fdd43f6b1b4c3dd133cfca53e0b1210bc557c2ae56006026b5ccdb5f52826f", - "image": "gcr.io/google-containers/kube-addon-manager:v6.3", "memory": { - "request": { + "limit": { "bytes": 52428800 + }, + "request": { + "bytes": 31457280 } - }, - "name": "kube-addon-manager", - "status": { - "phase": "running", - "ready": true, - "restarts": 2 } }, "namespace": "kube-system", - "node": { - "name": "minikube" - }, "pod": { - "name": "kube-addon-manager-minikube" + "name": "kube-state-metrics-1303537707-mnzbp" } }, "metricset": { @@ -329,6 +330,10 @@ { "container": { "id": "3aaee8bdd311c015240e99fa2a5a5f2f26b11b51236a683b39d8c1902e423978", + "image": { + "name": "gcr.io/google_containers/kubernetes-dashboard-amd64:v1.5.1" + }, + "name": "kubernetes-dashboard", "runtime": "docker" }, "event": { @@ -339,8 +344,6 @@ "kubernetes": { "container": { "id": "docker://3aaee8bdd311c015240e99fa2a5a5f2f26b11b51236a683b39d8c1902e423978", - "image": "gcr.io/google_containers/kubernetes-dashboard-amd64:v1.5.1", - "name": "kubernetes-dashboard", "status": { "phase": "running", "ready": true, @@ -366,7 +369,11 @@ }, { "container": { - "id": "fa3d83f648de42492b38fa3e8501d109376f391c50f2bd210c895c8477ae4b62-test", + "id": "4fa227874ee68536bf902394fb662f07b99099798ca9cd5c1506b79075acc065", + "image": { + "name": "bitnami/redis:3.2.8-r2" + }, + "name": "jumpy-owl-redis", "runtime": "docker" }, "event": { @@ -378,32 +385,27 @@ "container": { "cpu": { "request": { - "cores": 0.2 + "cores": 0.1 } }, - "id": "docker://fa3d83f648de42492b38fa3e8501d109376f391c50f2bd210c895c8477ae4b62-test", - "image": "gcr.io/google_containers/kubedns-amd64:1.9-test", + "id": "docker://4fa227874ee68536bf902394fb662f07b99099798ca9cd5c1506b79075acc065", "memory": { - "limit": { - "bytes": 278257920 - }, "request": { - "bytes": 83400320 + "bytes": 268435456 } }, - "name": "kubedns", "status": { - "phase": "terminated", + "phase": "waiting", "ready": false, - "restarts": 3 + "restarts": 270 } }, - "namespace": "test", + "namespace": "default", "node": { - "name": "minikube-test" + "name": "minikube" }, "pod": { - "name": "kube-dns-v20-5g5cb-test" + "name": "jumpy-owl-redis-3481028193-s78x9" } }, "metricset": { @@ -417,7 +419,11 @@ }, { "container": { - "id": "52fa55e051dc5b68e44c027588685b7edd85aaa03b07f7216d399249ff4fc821", + "id": "973cbe45982c5126a5caf8c58d964c0ab1d5bb2c165ccc59715fcc1ebd58ab3d", + "image": { + "name": "gcr.io/google_containers/kube-state-metrics:v0.4.1" + }, + "name": "kube-state-metrics", "runtime": "docker" }, "event": { @@ -428,25 +434,26 @@ "kubernetes": { "container": { "cpu": { + "limit": { + "cores": 0.2 + }, "request": { - "cores": 0.01 + "cores": 0.1 } }, - "id": "docker://52fa55e051dc5b68e44c027588685b7edd85aaa03b07f7216d399249ff4fc821", - "image": "gcr.io/google_containers/exechealthz-amd64:1.2", + "id": "docker://973cbe45982c5126a5caf8c58d964c0ab1d5bb2c165ccc59715fcc1ebd58ab3d", "memory": { "limit": { "bytes": 52428800 }, "request": { - "bytes": 52428800 + "bytes": 31457280 } }, - "name": "healthz", "status": { "phase": "running", "ready": true, - "restarts": 2 + "restarts": 1 } }, "namespace": "kube-system", @@ -454,7 +461,7 @@ "name": "minikube" }, "pod": { - "name": "kube-dns-v20-5g5cb" + "name": "kube-state-metrics-1303537707-7ncd1" } }, "metricset": { @@ -468,7 +475,11 @@ }, { "container": { - "id": "469f5d2b7854eb52e5d13dc0cd3e664c1b682b157aabaf596ffe4984f1516902", + "id": "52fa55e051dc5b68e44c027588685b7edd85aaa03b07f7216d399249ff4fc821", + "image": { + "name": "gcr.io/google_containers/exechealthz-amd64:1.2" + }, + "name": "healthz", "runtime": "docker" }, "event": { @@ -478,13 +489,24 @@ }, "kubernetes": { "container": { - "id": "docker://469f5d2b7854eb52e5d13dc0cd3e664c1b682b157aabaf596ffe4984f1516902", - "image": "gcr.io/kubernetes-helm/tiller:v2.3.1", - "name": "tiller", + "cpu": { + "request": { + "cores": 0.01 + } + }, + "id": "docker://52fa55e051dc5b68e44c027588685b7edd85aaa03b07f7216d399249ff4fc821", + "memory": { + "limit": { + "bytes": 52428800 + }, + "request": { + "bytes": 52428800 + } + }, "status": { "phase": "running", "ready": true, - "restarts": 1 + "restarts": 2 } }, "namespace": "kube-system", @@ -492,7 +514,7 @@ "name": "minikube" }, "pod": { - "name": "tiller-deploy-3067024529-9lpmb" + "name": "kube-dns-v20-5g5cb" } }, "metricset": { diff --git a/metricbeat/module/kubernetes/state_container/state_container.go b/metricbeat/module/kubernetes/state_container/state_container.go index 26c26f20637..fc48c84f7dd 100644 --- a/metricbeat/module/kubernetes/state_container/state_container.go +++ b/metricbeat/module/kubernetes/state_container/state_container.go @@ -63,12 +63,12 @@ var ( Labels: map[string]p.LabelMap{ "pod": p.KeyLabel(mb.ModuleDataKey + ".pod.name"), - "container": p.KeyLabel("name"), // this will be moved to ECS container.name through alias type + "container": p.KeyLabel("name"), "namespace": p.KeyLabel(mb.ModuleDataKey + ".namespace"), "node": p.Label(mb.ModuleDataKey + ".node.name"), "container_id": p.Label("id"), - "image": p.Label("image"), // this will be moved to ECS container.image.name through alias type + "image": p.Label("image"), }, } ) @@ -147,6 +147,17 @@ func (m *MetricSet) Fetch(reporter mb.ReporterV2) error { containerFields.Put("id", cID[split+3:]) } } + if containerImage, ok := event["image"]; ok { + cImage := (containerImage).(string) + containerFields.Put("image.name", cImage) + } + if containerName, ok := event["name"]; ok { + cName := (containerName).(string) + containerFields.Put("name", cName) + } + // remove ECS container fields from kubernetes.container.* since they will be set through alias + event.Delete("image") + event.Delete("name") if len(containerFields) > 0 { rootFields = common.MapStr{ "container": containerFields,