Skip to content

Commit

Permalink
Add kubernetes.pod.status_reason and kubernetes.pod.status.ready_time…
Browse files Browse the repository at this point in the history
… fields in Kubernetes state_pod metricset (#39316)

* Add kubernetes.pod.status_reason and kubernetes.pod.status.ready_time fields

* Update tests and docs

* Declare timestamp field as double

* Add evicted pod ksm

* Changelog entry

* Update field description
  • Loading branch information
MichaelKatsoulis authored May 8, 2024
1 parent f5bb642 commit d1089d1
Show file tree
Hide file tree
Showing 14 changed files with 452 additions and 333 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Add SSL support to mysql module {pull}37997[37997]
- Add SSL support for aerospike module {pull}38126[38126]
- Add last_terminated_timestamp metric in kubernetes module {pull}39200[39200] {issue}3802[3802]
- Add pod.status.ready_time and pod.status.reason metrics in kubernetes module {pull}39316[39316]


*Metricbeat*
Expand Down
20 changes: 20 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -46811,6 +46811,26 @@ type: keyword

--

*`kubernetes.pod.status.reason`*::
+
--
The reason the pod is in its current state (Evicted, NodeAffinity, NodeLost, Shutdown or UnexpectedAdmissionError)


type: keyword

--

*`kubernetes.pod.status.ready_time`*::
+
--
Readiness achieved time in unix timestamp for a pod


type: double

--

[float]
=== replicaset

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ kube_pod_status_container_ready_time{namespace="kube-system",pod="kube-scheduler
kube_pod_status_container_ready_time{namespace="kube-system",pod="coredns-76f75df574-v8skx",uid="b02dd54a-7c6b-4a45-8f42-cbc00c6fb040"} 1.713862204e+09
# HELP kube_pod_status_reason The pod status reasons
# TYPE kube_pod_status_reason gauge
kube_pod_status_reason{namespace="default",pod="web-0",uid="37dd3592-b439-4090-a233-49b8faa2b9b3",reason="Evicted"} 0
kube_pod_status_reason{namespace="default",pod="web-0",uid="37dd3592-b439-4090-a233-49b8faa2b9b3",reason="Evicted"} 1
kube_pod_status_reason{namespace="default",pod="web-0",uid="37dd3592-b439-4090-a233-49b8faa2b9b3",reason="NodeAffinity"} 0
kube_pod_status_reason{namespace="default",pod="web-0",uid="37dd3592-b439-4090-a233-49b8faa2b9b3",reason="NodeLost"} 0
kube_pod_status_reason{namespace="default",pod="web-0",uid="37dd3592-b439-4090-a233-49b8faa2b9b3",reason="Shutdown"} 0
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/kubernetes/fields.go

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions metricbeat/module/kubernetes/state_pod/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"module": "kubernetes"
},
"kubernetes": {
"namespace": "kube-system",
"namespace": "default",
"node": {
"name": "kind-control-plane"
},
"pod": {
"host_ip": "172.21.0.2",
"ip": "172.21.0.2",
"name": "etcd-kind-control-plane",
"ip": "10.244.0.173",
"name": "hello-28564555-zdfjz",
"status": {
"phase": "running",
"ready": "true",
"phase": "succeeded",
"ready": "false",
"scheduled": "true"
}
}
Expand Down
8 changes: 8 additions & 0 deletions metricbeat/module/kubernetes/state_pod/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@
type: keyword
description: >
Kubernetes pod scheduled status (true, false, unknown)
- name: reason
type: keyword
description: >
The reason the pod is in its current state (Evicted, NodeAffinity, NodeLost, Shutdown or UnexpectedAdmissionError)
- name: ready_time
type: double
description: >
Readiness achieved time in unix timestamp for a pod
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
{
"RootFields": null,
"ModuleFields": {
"namespace": "local-path-storage",
"namespace": "kube-system",
"node": {
"name": "kind-control-plane"
}
},
"MetricSetFields": {
"host_ip": "172.18.0.2",
"ip": "10.244.0.2",
"name": "local-path-provisioner-6bc4bddd6b-6vl7d",
"ip": "10.244.0.5",
"name": "kube-state-metrics-7857446fb4-x78j6",
"status": {
"phase": "running",
"ready": "true",
"ready_time": 1698751133,
"scheduled": "true"
}
},
Expand All @@ -39,10 +40,11 @@
"MetricSetFields": {
"host_ip": "172.18.0.2",
"ip": "172.18.0.2",
"name": "kube-proxy-2nq9k",
"name": "kube-scheduler-kind-control-plane",
"status": {
"phase": "running",
"ready": "true",
"ready_time": 1698675684,
"scheduled": "true"
}
},
Expand All @@ -60,18 +62,19 @@
{
"RootFields": null,
"ModuleFields": {
"namespace": "default",
"namespace": "kube-system",
"node": {
"name": "kind-control-plane"
}
},
"MetricSetFields": {
"host_ip": "172.18.0.2",
"ip": "10.244.0.8",
"name": "hello-mwrpw",
"ip": "172.18.0.2",
"name": "kube-controller-manager-kind-control-plane",
"status": {
"phase": "succeeded",
"ready": "false",
"phase": "running",
"ready": "true",
"ready_time": 1698675686,
"scheduled": "true"
}
},
Expand All @@ -96,11 +99,12 @@
},
"MetricSetFields": {
"host_ip": "172.18.0.2",
"ip": "10.244.0.7",
"name": "fluentd-elasticsearch-m2tlp",
"ip": "10.244.0.3",
"name": "coredns-5d78c9869d-crtn9",
"status": {
"phase": "running",
"ready": "true",
"ready_time": 1698675701,
"scheduled": "true"
}
},
Expand All @@ -125,8 +129,8 @@
},
"MetricSetFields": {
"host_ip": "172.18.0.2",
"ip": "10.244.0.9",
"name": "hello-28312520-d5d5s",
"ip": "10.244.0.8",
"name": "hello-mwrpw",
"status": {
"phase": "succeeded",
"ready": "false",
Expand Down Expand Up @@ -154,11 +158,12 @@
},
"MetricSetFields": {
"host_ip": "172.18.0.2",
"ip": "10.244.0.3",
"name": "coredns-5d78c9869d-crtn9",
"ip": "10.244.0.4",
"name": "coredns-5d78c9869d-gskzq",
"status": {
"phase": "running",
"ready": "true",
"ready_time": 1698675701,
"scheduled": "true"
}
},
Expand All @@ -176,18 +181,18 @@
{
"RootFields": null,
"ModuleFields": {
"namespace": "kube-system",
"namespace": "default",
"node": {
"name": "kind-control-plane"
}
},
"MetricSetFields": {
"host_ip": "172.18.0.2",
"ip": "10.244.0.4",
"name": "coredns-5d78c9869d-gskzq",
"ip": "10.244.0.9",
"name": "hello-28312520-d5d5s",
"status": {
"phase": "running",
"ready": "true",
"phase": "succeeded",
"ready": "false",
"scheduled": "true"
}
},
Expand All @@ -213,10 +218,11 @@
"MetricSetFields": {
"host_ip": "172.18.0.2",
"ip": "172.18.0.2",
"name": "kube-scheduler-kind-control-plane",
"name": "kindnet-xg6gs",
"status": {
"phase": "running",
"ready": "true",
"ready_time": 1698675698,
"scheduled": "true"
}
},
Expand All @@ -241,11 +247,12 @@
},
"MetricSetFields": {
"host_ip": "172.18.0.2",
"ip": "10.244.0.5",
"name": "kube-state-metrics-7857446fb4-x78j6",
"ip": "10.244.0.7",
"name": "fluentd-elasticsearch-m2tlp",
"status": {
"phase": "running",
"ready": "true",
"ready_time": 1698751174,
"scheduled": "true"
}
},
Expand All @@ -271,10 +278,11 @@
"MetricSetFields": {
"host_ip": "172.18.0.2",
"ip": "172.18.0.2",
"name": "kube-controller-manager-kind-control-plane",
"name": "etcd-kind-control-plane",
"status": {
"phase": "running",
"ready": "true",
"ready_time": 1698675692,
"scheduled": "true"
}
},
Expand All @@ -300,10 +308,11 @@
"MetricSetFields": {
"host_ip": "172.18.0.2",
"ip": "172.18.0.2",
"name": "kindnet-xg6gs",
"name": "kube-apiserver-kind-control-plane",
"status": {
"phase": "running",
"ready": "true",
"ready_time": 1698675692,
"scheduled": "true"
}
},
Expand All @@ -321,18 +330,19 @@
{
"RootFields": null,
"ModuleFields": {
"namespace": "kube-system",
"namespace": "default",
"node": {
"name": "kind-control-plane"
}
},
"MetricSetFields": {
"host_ip": "172.18.0.2",
"ip": "172.18.0.2",
"name": "kube-apiserver-kind-control-plane",
"ip": "10.244.0.6",
"name": "web-0",
"status": {
"phase": "running",
"ready": "true",
"ready_time": 1698751165,
"scheduled": "true"
}
},
Expand All @@ -350,18 +360,19 @@
{
"RootFields": null,
"ModuleFields": {
"namespace": "default",
"namespace": "local-path-storage",
"node": {
"name": "kind-control-plane"
}
},
"MetricSetFields": {
"host_ip": "172.18.0.2",
"ip": "10.244.0.6",
"name": "web-0",
"ip": "10.244.0.2",
"name": "local-path-provisioner-6bc4bddd6b-6vl7d",
"status": {
"phase": "running",
"ready": "true",
"ready_time": 1698675701,
"scheduled": "true"
}
},
Expand All @@ -387,10 +398,11 @@
"MetricSetFields": {
"host_ip": "172.18.0.2",
"ip": "172.18.0.2",
"name": "etcd-kind-control-plane",
"name": "kube-proxy-2nq9k",
"status": {
"phase": "running",
"ready": "true",
"ready_time": 1698675697,
"scheduled": "true"
}
},
Expand Down
Loading

0 comments on commit d1089d1

Please sign in to comment.