Skip to content

Commit

Permalink
Add pod.ip in k8s metadata (elastic#25037)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrsMark authored Apr 14, 2021
1 parent e8afb8d commit c473af2
Show file tree
Hide file tree
Showing 24 changed files with 163 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Add `wineventlog` schema to `decode_xml` processor. {issue}23910[23910] {pull}24726[24726]
- Add new ECS 1.9 field `cloud.service.name` to `add_cloud_metadata` processor. {pull}24993[24993]
- Libbeat: report queue capacity, output batch size, and output client count to monitoring. {pull}24700[24700]
- Add kubernetes.pod.ip field in kubernetes metadata. {pull}25037[25037]

*Auditbeat*

Expand Down
10 changes: 10 additions & 0 deletions auditbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -12397,6 +12397,16 @@ type: keyword
--
*`kubernetes.pod.ip`*::
+
--
Kubernetes Pod IP
type: ip
--
*`kubernetes.namespace`*::
+
--
Expand Down
2 changes: 1 addition & 1 deletion auditbeat/include/fields.go

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions filebeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -87194,6 +87194,16 @@ type: keyword

--

*`kubernetes.pod.ip`*::
+
--
Kubernetes Pod IP


type: ip

--

*`kubernetes.namespace`*::
+
--
Expand Down
2 changes: 1 addition & 1 deletion filebeat/include/fields.go

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions heartbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9979,6 +9979,16 @@ type: keyword
--
*`kubernetes.pod.ip`*::
+
--
Kubernetes Pod IP
type: ip
--
*`kubernetes.namespace`*::
+
--
Expand Down
2 changes: 1 addition & 1 deletion heartbeat/include/fields.go

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions journalbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -10324,6 +10324,16 @@ type: keyword
--
*`kubernetes.pod.ip`*::
+
--
Kubernetes Pod IP
type: ip
--
*`kubernetes.namespace`*::
+
--
Expand Down
2 changes: 1 addition & 1 deletion journalbeat/include/fields.go

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions libbeat/autodiscover/providers/kubernetes/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
},
"node": common.MapStr{
"name": "node",
Expand All @@ -413,6 +414,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
}, "node": common.MapStr{
"name": "node",
},
Expand All @@ -436,6 +438,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
},
"node": common.MapStr{
"name": "node",
Expand All @@ -449,6 +452,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
Expand Down Expand Up @@ -523,6 +527,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
},
"node": common.MapStr{
"name": "node",
Expand All @@ -536,6 +541,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
}, "node": common.MapStr{
"name": "node",
},
Expand All @@ -559,6 +565,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
},
"node": common.MapStr{
"name": "node",
Expand All @@ -572,6 +579,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
Expand Down Expand Up @@ -602,6 +610,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
},
"node": common.MapStr{
"name": "node",
Expand All @@ -615,6 +624,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
Expand Down Expand Up @@ -841,6 +851,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
},
"node": common.MapStr{
"name": "node",
Expand All @@ -854,6 +865,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
}, "node": common.MapStr{
"name": "node",
},
Expand All @@ -877,6 +889,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
},
"node": common.MapStr{
"name": "node",
Expand All @@ -890,6 +903,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
Expand Down Expand Up @@ -947,6 +961,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
},
"node": common.MapStr{
"name": "node",
Expand All @@ -960,6 +975,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
}, "node": common.MapStr{
"name": "node",
},
Expand All @@ -983,6 +999,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
},
"node": common.MapStr{
"name": "node",
Expand All @@ -996,6 +1013,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
Expand Down Expand Up @@ -1057,6 +1075,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
},
"node": common.MapStr{
"name": "node",
Expand All @@ -1070,6 +1089,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
}, "node": common.MapStr{
"name": "node",
},
Expand All @@ -1093,6 +1113,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
},
"node": common.MapStr{
"name": "node",
Expand All @@ -1106,6 +1127,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
Expand Down Expand Up @@ -1169,6 +1191,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
},
"node": common.MapStr{
"name": "node",
Expand All @@ -1182,6 +1205,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
}, "node": common.MapStr{
"name": "node",
},
Expand All @@ -1205,6 +1229,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
},
"node": common.MapStr{
"name": "node",
Expand All @@ -1218,6 +1243,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
Expand Down Expand Up @@ -1312,6 +1338,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
},
"node": common.MapStr{
"name": "node",
Expand All @@ -1325,6 +1352,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
}, "node": common.MapStr{
"name": "node",
},
Expand All @@ -1349,6 +1377,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
},
"node": common.MapStr{
"name": "node",
Expand All @@ -1362,6 +1391,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
Expand Down Expand Up @@ -1393,6 +1423,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
},
"node": common.MapStr{
"name": "node",
Expand All @@ -1406,6 +1437,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
Expand Down Expand Up @@ -1437,6 +1469,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
},
"node": common.MapStr{
"name": "node",
Expand All @@ -1450,6 +1483,7 @@ func TestEmitEvent(t *testing.T) {
"pod": common.MapStr{
"name": "filebeat",
"uid": "005f3b90-4b9d-12f8-acf0-31020a840133",
"ip": podIP,
}, "node": common.MapStr{
"name": "node",
}, "container": common.MapStr{
Expand Down
5 changes: 5 additions & 0 deletions libbeat/common/kubernetes/metadata/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ func (p *pod) Generate(obj kubernetes.Resource, opts ...FieldOptions) common.Map
out.DeepUpdate(meta)
}
}

if po.Status.PodIP != "" {
out.Put("pod.ip", po.Status.PodIP)
}

return out
}

Expand Down
Loading

0 comments on commit c473af2

Please sign in to comment.