@@ -64,7 +64,9 @@ func podMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat
64
64
createPodInitContainerInfoFamilyGenerator (),
65
65
createPodInitContainerResourceLimitsFamilyGenerator (),
66
66
createPodInitContainerResourceRequestsFamilyGenerator (),
67
+ createPodInitContainerStateStartedFamilyGenerator (),
67
68
createPodInitContainerStatusLastTerminatedReasonFamilyGenerator (),
69
+ createPodInitContainerStatusLastTerminatedTimestampFamilyGenerator (),
68
70
createPodInitContainerStatusReadyFamilyGenerator (),
69
71
createPodInitContainerStatusRestartsTotalFamilyGenerator (),
70
72
createPodInitContainerStatusRunningFamilyGenerator (),
@@ -858,6 +860,39 @@ func createPodInitContainerResourceRequestsFamilyGenerator() generator.FamilyGen
858
860
)
859
861
}
860
862
863
+ func createPodInitContainerStateStartedFamilyGenerator () generator.FamilyGenerator {
864
+ return * generator .NewFamilyGeneratorWithStability (
865
+ "kube_pod_init_container_state_started" ,
866
+ "Start time in unix timestamp for a pod init container." ,
867
+ metric .Gauge ,
868
+ basemetrics .ALPHA ,
869
+ "" ,
870
+ wrapPodFunc (func (p * v1.Pod ) * metric.Family {
871
+ ms := []* metric.Metric {}
872
+
873
+ for _ , cs := range p .Status .InitContainerStatuses {
874
+ if cs .State .Running != nil {
875
+ ms = append (ms , & metric.Metric {
876
+ LabelKeys : []string {"container" },
877
+ LabelValues : []string {cs .Name },
878
+ Value : float64 ((cs .State .Running .StartedAt ).Unix ()),
879
+ })
880
+ } else if cs .State .Terminated != nil {
881
+ ms = append (ms , & metric.Metric {
882
+ LabelKeys : []string {"container" },
883
+ LabelValues : []string {cs .Name },
884
+ Value : float64 ((cs .State .Terminated .StartedAt ).Unix ()),
885
+ })
886
+ }
887
+ }
888
+
889
+ return & metric.Family {
890
+ Metrics : ms ,
891
+ }
892
+ }),
893
+ )
894
+ }
895
+
861
896
func createPodInitContainerStatusLastTerminatedReasonFamilyGenerator () generator.FamilyGenerator {
862
897
return * generator .NewFamilyGeneratorWithStability (
863
898
"kube_pod_init_container_status_last_terminated_reason" ,
@@ -883,6 +918,32 @@ func createPodInitContainerStatusLastTerminatedReasonFamilyGenerator() generator
883
918
)
884
919
}
885
920
921
+ func createPodInitContainerStatusLastTerminatedTimestampFamilyGenerator () generator.FamilyGenerator {
922
+ return * generator .NewFamilyGeneratorWithStability (
923
+ "kube_pod_init_container_status_last_terminated_timestamp" ,
924
+ "Last terminated time for a pod init container in unix timestamp." ,
925
+ metric .Gauge ,
926
+ basemetrics .ALPHA ,
927
+ "" ,
928
+ wrapPodFunc (func (p * v1.Pod ) * metric.Family {
929
+ ms := make ([]* metric.Metric , 0 , len (p .Status .ContainerStatuses ))
930
+ for _ , cs := range p .Status .InitContainerStatuses {
931
+ if cs .LastTerminationState .Terminated != nil {
932
+ ms = append (ms , & metric.Metric {
933
+ LabelKeys : []string {"container" },
934
+ LabelValues : []string {cs .Name },
935
+ Value : float64 (cs .LastTerminationState .Terminated .FinishedAt .Unix ()),
936
+ })
937
+ }
938
+ }
939
+
940
+ return & metric.Family {
941
+ Metrics : ms ,
942
+ }
943
+ }),
944
+ )
945
+ }
946
+
886
947
func createPodInitContainerStatusReadyFamilyGenerator () generator.FamilyGenerator {
887
948
return * generator .NewFamilyGeneratorWithStability (
888
949
"kube_pod_init_container_status_ready" ,
0 commit comments