diff --git a/internal/store/pod.go b/internal/store/pod.go index 735d94792c..09a83d171b 100644 --- a/internal/store/pod.go +++ b/internal/store/pod.go @@ -677,7 +677,7 @@ func createPodInitContainerInfoFamilyGenerator() generator.FamilyGenerator { "", wrapPodFunc(func(p *v1.Pod) *metric.Family { ms := []*metric.Metric{} - labelKeys := []string{"container", "image_spec", "image", "image_id", "container_id", "type"} + labelKeys := []string{"container", "image_spec", "image", "image_id", "container_id", "restart_policy"} for _, c := range p.Spec.InitContainers { restartPolicy := "" diff --git a/internal/store/pod_test.go b/internal/store/pod_test.go index 4bab61241a..84f63cadb4 100644 --- a/internal/store/pod_test.go +++ b/internal/store/pod_test.go @@ -88,8 +88,8 @@ func TestPodStore(t *testing.T) { }, InitContainers: []v1.Container{ { - Name: "initContainer", - Image: "k8s.gcr.io/initfoo_spec", + Name: "initContainer", + Image: "k8s.gcr.io/initfoo_spec", RestartPolicy: &restartPolicyAlways, }, }, @@ -126,7 +126,7 @@ func TestPodStore(t *testing.T) { # TYPE kube_pod_init_container_info gauge kube_pod_container_info{container="container2",container_id="docker://cd456",image_spec="k8s.gcr.io/hyperkube2_spec",image="k8s.gcr.io/hyperkube2",image_id="docker://sha256:bbb",namespace="ns2",pod="pod2",uid="uid2"} 1 kube_pod_container_info{container="container3",container_id="docker://ef789",image_spec="k8s.gcr.io/hyperkube3_spec",image="k8s.gcr.io/hyperkube3",image_id="docker://sha256:ccc",namespace="ns2",pod="pod2",uid="uid2"} 1 - kube_pod_init_container_info{container="initContainer",container_id="docker://ef123",image_spec="k8s.gcr.io/initfoo_spec",image="k8s.gcr.io/initfoo",image_id="docker://sha256:wxyz",namespace="ns2",pod="pod2",uid="uid2",type="Always"} 1`, + kube_pod_init_container_info{container="initContainer",container_id="docker://ef123",image_spec="k8s.gcr.io/initfoo_spec",image="k8s.gcr.io/initfoo",image_id="docker://sha256:wxyz",namespace="ns2",pod="pod2",uid="uid2",restart_policy="Always"} 1`, MetricNames: []string{"kube_pod_container_info", "kube_pod_init_container_info"}, }, {