Skip to content

Commit

Permalink
[metricbeat] [kubernetes] Make sure the active phase status is retrie…
Browse files Browse the repository at this point in the history
…ved for kubernetes pods in state_pod (#5980)

Make sure the active phase status is retrieved for kubernetes pods
  • Loading branch information
Crazybus authored and exekias committed Jan 4, 2018
1 parent b3684a4 commit 45cb784
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di
- Fix incorrect `Mem.Used` calculation under linux. {pull}5775[5775]
- Fix mongodb session consistency mode to allow command execution on secondary nodes. {issue}4689[4689]
- Fix `open_file_descriptor_count` and `max_file_descriptor_count` lost in zookeeper module {pull}5902[5902]
- Fix kubernetes `state_pod` `status.phase` so that the active phase is returned instead of `unknown`. {pull}5980[5980]

*Packetbeat*

Expand Down
4 changes: 3 additions & 1 deletion metricbeat/module/kubernetes/_meta/test/kube-state-metrics
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@ kube_pod_info{host_ip="192.168.99.100",namespace="kube-system",node="minikube",p
kube_pod_info{host_ip="192.168.99.100",namespace="kube-system",node="minikube",pod="tiller-deploy-3067024529-9lpmb",pod_ip="172.17.0.2"} 1
# HELP kube_pod_status_phase The pods current phase.
# TYPE kube_pod_status_phase gauge
kube_pod_status_phase{namespace="default",phase="Running",pod="jumpy-owl-redis-3481028193-s78x9"} 1
kube_pod_status_phase{namespace="default",phase="Running",pod="jumpy-owl-redis-3481028193-s78x9"} 0
kube_pod_status_phase{namespace="default",phase="Succeeded",pod="jumpy-owl-redis-3481028193-s78x9"} 1
kube_pod_status_phase{namespace="default",phase="Unknown",pod="jumpy-owl-redis-3481028193-s78x9"} 0
kube_pod_status_phase{namespace="jenkins",phase="Running",pod="wise-lynx-jenkins-1616735317-svn6k"} 1
kube_pod_status_phase{namespace="kube-system",phase="Pending",pod="kube-state-metrics-1303537707-mnzbp"} 1
kube_pod_status_phase{namespace="kube-system",phase="Running",pod="kube-addon-manager-minikube"} 1
Expand Down
4 changes: 3 additions & 1 deletion metricbeat/module/kubernetes/state_pod/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ func eventMapping(families []*dto.MetricFamily) ([]common.MapStr, error) {
}

case "kube_pod_status_phase":
event.Put("status.phase", strings.ToLower(util.GetLabel(metric, "phase")))
if metric.GetGauge().GetValue() == 1 {
event.Put("status.phase", strings.ToLower(util.GetLabel(metric, "phase")))
}

case "kube_pod_status_ready":
if metric.GetGauge().GetValue() == 1 {
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/kubernetes/state_pod/state_pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestEventMapping(t *testing.T) {
"host_ip": "192.168.99.100",
"ip": "172.17.0.4",

"status.phase": "running",
"status.phase": "succeeded",
"status.ready": "false",
"status.scheduled": "true",
}
Expand Down

0 comments on commit 45cb784

Please sign in to comment.