diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index a621206477e..7dfd379eebc 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -79,6 +79,7 @@ https://github.com/elastic/beats/compare/v6.4.0...master[Check the HEAD diff] - Add docker diskio stats on Windows. {issue}6815[6815] {pull}8126[8126] - Fix incorrect type conversion of average response time in Haproxy dashboards {pull}8404[8404] - Fix dropwizard module parsing of metric names. {issue}8365[8365] {pull}6385[8385] +- Avoid mapping issues in kubernetes module. {pull}8487[8487] *Packetbeat* diff --git a/metricbeat/module/kubernetes/container/data.go b/metricbeat/module/kubernetes/container/data.go index b48677ec480..93e6f9bc620 100644 --- a/metricbeat/module/kubernetes/container/data.go +++ b/metricbeat/module/kubernetes/container/data.go @@ -52,8 +52,7 @@ func eventMapping(content []byte, perfMetrics *util.PerfMetricsCache) ([]common. }, }, - "name": container.Name, - "start_time": container.StartTime, + "name": container.Name, "cpu": common.MapStr{ "usage": common.MapStr{ @@ -114,6 +113,10 @@ func eventMapping(content []byte, perfMetrics *util.PerfMetricsCache) ([]common. }, } + if container.StartTime != "" { + containerEvent.Put("start_time", container.StartTime) + } + if nodeCores > 0 { containerEvent.Put("cpu.usage.node.pct", float64(container.CPU.UsageNanoCores)/1e9/nodeCores) } diff --git a/metricbeat/module/kubernetes/event/_meta/fields.yml b/metricbeat/module/kubernetes/event/_meta/fields.yml index 82f09cfdf1f..d33a70e79c9 100644 --- a/metricbeat/module/kubernetes/event/_meta/fields.yml +++ b/metricbeat/module/kubernetes/event/_meta/fields.yml @@ -9,18 +9,17 @@ type: long description: > Count field records the number of times the particular event has occurred + - name: timestamp + type: group fields: - - name: timestamp - type: group - fields: - - name: first_occurrence - type: date - description: > - Timestamp of first occurrence of event - - name: last_occurrence - type: date - description: > - Timestamp of last occurrence of event + - name: first_occurrence + type: date + description: > + Timestamp of first occurrence of event + - name: last_occurrence + type: date + description: > + Timestamp of last occurrence of event - name: message type: keyword description: > diff --git a/metricbeat/module/kubernetes/node/data.go b/metricbeat/module/kubernetes/node/data.go index fe86dd732de..0d055880ee6 100644 --- a/metricbeat/module/kubernetes/node/data.go +++ b/metricbeat/module/kubernetes/node/data.go @@ -34,8 +34,7 @@ func eventMapping(content []byte) (common.MapStr, error) { node := summary.Node nodeEvent := common.MapStr{ - "name": node.NodeName, - "start_time": node.StartTime, + "name": node.NodeName, "cpu": common.MapStr{ "usage": common.MapStr{ @@ -105,5 +104,10 @@ func eventMapping(content []byte) (common.MapStr, error) { }, }, } + + if node.StartTime != "" { + nodeEvent.Put("start_time", node.StartTime) + } + return nodeEvent, nil } diff --git a/metricbeat/module/kubernetes/pod/data.go b/metricbeat/module/kubernetes/pod/data.go index 91e8b184559..1619b172ef9 100644 --- a/metricbeat/module/kubernetes/pod/data.go +++ b/metricbeat/module/kubernetes/pod/data.go @@ -58,8 +58,7 @@ func eventMapping(content []byte, perfMetrics *util.PerfMetricsCache) ([]common. "name": node.NodeName, }, }, - "name": pod.PodRef.Name, - "start_time": pod.StartTime, + "name": pod.PodRef.Name, "cpu": common.MapStr{ "usage": common.MapStr{ @@ -85,6 +84,10 @@ func eventMapping(content []byte, perfMetrics *util.PerfMetricsCache) ([]common. }, } + if pod.StartTime != "" { + podEvent.Put("start_time", pod.StartTime) + } + if coresLimit > nodeCores { coresLimit = nodeCores } diff --git a/metricbeat/module/kubernetes/system/data.go b/metricbeat/module/kubernetes/system/data.go index 2ade2e596c2..6cf09f85335 100644 --- a/metricbeat/module/kubernetes/system/data.go +++ b/metricbeat/module/kubernetes/system/data.go @@ -44,8 +44,7 @@ func eventMapping(content []byte) ([]common.MapStr, error) { "name": node.NodeName, }, }, - "container": syscontainer.Name, - "start_time": syscontainer.StartTime, + "container": syscontainer.Name, "cpu": common.MapStr{ "usage": common.MapStr{ "nanocores": syscontainer.CPU.UsageNanoCores, @@ -68,6 +67,11 @@ func eventMapping(content []byte) ([]common.MapStr, error) { "majorpagefaults": syscontainer.Memory.MajorPageFaults, }, } + + if syscontainer.StartTime != "" { + containerEvent.Put("start_time", syscontainer.StartTime) + } + events = append(events, containerEvent) }