@@ -365,6 +365,56 @@ func TestPodStore(t *testing.T) {
365365 "kube_pod_init_container_status_terminated_reason" ,
366366 },
367367 },
368+ {
369+ Obj : & v1.Pod {
370+ ObjectMeta : metav1.ObjectMeta {
371+ Name : "pod1" ,
372+ Namespace : "ns1" ,
373+ UID : "uid1" ,
374+ },
375+ Status : v1.PodStatus {
376+ ContainerStatuses : []v1.ContainerStatus {
377+ {
378+ Name : "container1" ,
379+ State : v1.ContainerState {
380+ Terminated : & v1.ContainerStateTerminated {
381+ StartedAt : metav1.Time {
382+ Time : time .Unix (1501777018 , 0 ),
383+ },
384+ Reason : "Completed" ,
385+ },
386+ },
387+ },
388+ },
389+ },
390+ },
391+ Want : `
392+ # HELP kube_pod_container_status_running Describes whether the container is currently in running state.
393+ # HELP kube_pod_container_state_started Start time in unix timestamp for a pod container.
394+ # HELP kube_pod_container_status_terminated Describes whether the container is currently in terminated state.
395+ # HELP kube_pod_container_status_terminated_reason Describes the reason the container is currently in terminated state.
396+ # HELP kube_pod_container_status_waiting Describes whether the container is currently in waiting state.
397+ # HELP kube_pod_container_status_waiting_reason Describes the reason the container is currently in waiting state.
398+ # TYPE kube_pod_container_status_running gauge
399+ # TYPE kube_pod_container_state_started gauge
400+ # TYPE kube_pod_container_status_terminated gauge
401+ # TYPE kube_pod_container_status_terminated_reason gauge
402+ # TYPE kube_pod_container_status_waiting gauge
403+ # TYPE kube_pod_container_status_waiting_reason gauge
404+ kube_pod_container_state_started{container="container1",namespace="ns1",pod="pod1",uid="uid1"} 1.501777018e+09
405+ kube_pod_container_status_running{container="container1",namespace="ns1",pod="pod1",uid="uid1"} 0
406+ kube_pod_container_status_terminated_reason{container="container1",namespace="ns1",pod="pod1",reason="Completed",uid="uid1"} 1
407+ kube_pod_container_status_terminated{container="container1",namespace="ns1",pod="pod1",uid="uid1"} 1
408+ kube_pod_container_status_waiting{container="container1",namespace="ns1",pod="pod1",uid="uid1"} 0
409+ ` ,
410+ MetricNames : []string {
411+ "kube_pod_container_status_running" ,
412+ "kube_pod_container_state_started" ,
413+ "kube_pod_container_status_waiting" ,
414+ "kube_pod_container_status_terminated" ,
415+ "kube_pod_container_status_terminated_reason" ,
416+ },
417+ },
368418 {
369419 Obj : & v1.Pod {
370420 ObjectMeta : metav1.ObjectMeta {
@@ -378,6 +428,9 @@ func TestPodStore(t *testing.T) {
378428 Name : "container2" ,
379429 State : v1.ContainerState {
380430 Terminated : & v1.ContainerStateTerminated {
431+ StartedAt : metav1.Time {
432+ Time : time .Unix (1501777018 , 0 ),
433+ },
381434 Reason : "OOMKilled" ,
382435 },
383436 },
@@ -395,17 +448,20 @@ func TestPodStore(t *testing.T) {
395448 },
396449 Want : `
397450 # HELP kube_pod_container_status_running Describes whether the container is currently in running state.
451+ # HELP kube_pod_container_state_started Start time in unix timestamp for a pod container.
398452 # HELP kube_pod_container_status_terminated Describes whether the container is currently in terminated state.
399453 # HELP kube_pod_container_status_terminated_reason Describes the reason the container is currently in terminated state.
400454 # HELP kube_pod_container_status_waiting Describes whether the container is currently in waiting state.
401455 # HELP kube_pod_container_status_waiting_reason Describes the reason the container is currently in waiting state.
402456 # TYPE kube_pod_container_status_running gauge
457+ # TYPE kube_pod_container_state_started gauge
403458 # TYPE kube_pod_container_status_terminated gauge
404459 # TYPE kube_pod_container_status_terminated_reason gauge
405460 # TYPE kube_pod_container_status_waiting gauge
406461 # TYPE kube_pod_container_status_waiting_reason gauge
407462 kube_pod_container_status_running{container="container2",namespace="ns2",pod="pod2",uid="uid2"} 0
408463 kube_pod_container_status_running{container="container3",namespace="ns2",pod="pod2",uid="uid2"} 0
464+ kube_pod_container_state_started{container="container2",namespace="ns2",pod="pod2",uid="uid2"} 1.501777018e+09
409465 kube_pod_container_status_terminated_reason{container="container2",namespace="ns2",pod="pod2",reason="OOMKilled",uid="uid2"} 1
410466 kube_pod_container_status_terminated{container="container2",namespace="ns2",pod="pod2",uid="uid2"} 1
411467 kube_pod_container_status_terminated{container="container3",namespace="ns2",pod="pod2",uid="uid2"} 0
@@ -415,6 +471,7 @@ func TestPodStore(t *testing.T) {
415471` ,
416472 MetricNames : []string {
417473 "kube_pod_container_status_running" ,
474+ "kube_pod_container_state_started" ,
418475 "kube_pod_container_status_waiting" ,
419476 "kube_pod_container_status_terminated" ,
420477 "kube_pod_container_status_terminated_reason" ,
0 commit comments