Skip to content

Commit

Permalink
Merge pull request #713 from chenk008/add_priority_class_kube_pod_info
Browse files Browse the repository at this point in the history
Add label for priority class in kube_pod_info #712
  • Loading branch information
k8s-ci-robot committed Apr 5, 2019
2 parents aed9485 + f3468ad commit 64b70f5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/pod-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

| Metric name| Metric type | Labels/tags | Status |
| ---------- | ----------- | ----------- | ----------- |
| kube_pod_info | Gauge | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `host_ip`=&lt;host-ip&gt; <br> `pod_ip`=&lt;pod-ip&gt; <br> `node`=&lt;node-name&gt;<br> `created_by_kind`=&lt;created_by_kind&gt;<br> `created_by_name`=&lt;created_by_name&gt;<br> `uid`=&lt;pod-uid&gt;| STABLE |
| kube_pod_info | Gauge | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `host_ip`=&lt;host-ip&gt; <br> `pod_ip`=&lt;pod-ip&gt; <br> `node`=&lt;node-name&gt;<br> `created_by_kind`=&lt;created_by_kind&gt;<br> `created_by_name`=&lt;created_by_name&gt;<br> `uid`=&lt;pod-uid&gt;<br> `priority_class`=&lt;priority_class&gt;| STABLE |
| kube_pod_start_time | Gauge | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; |
| kube_pod_completion_time | Gauge | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; | STABLE |
| kube_pod_owner | Gauge | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `owner_kind`=&lt;owner kind&gt; <br> `owner_name`=&lt;owner name&gt; <br> `owner_is_controller`=&lt;whether owner is controller&gt; | STABLE |
Expand Down
4 changes: 2 additions & 2 deletions internal/collector/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ var (

m := metric.Metric{

LabelKeys: []string{"host_ip", "pod_ip", "uid", "node", "created_by_kind", "created_by_name"},
LabelValues: []string{p.Status.HostIP, p.Status.PodIP, string(p.UID), p.Spec.NodeName, createdByKind, createdByName},
LabelKeys: []string{"host_ip", "pod_ip", "uid", "node", "created_by_kind", "created_by_name", "priority_class"},
LabelValues: []string{p.Status.HostIP, p.Status.PodIP, string(p.UID), p.Spec.NodeName, createdByKind, createdByName, p.Spec.PriorityClassName},
Value: 1,
}

Expand Down
7 changes: 4 additions & 3 deletions internal/collector/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,8 @@ kube_pod_container_status_last_terminated_reason{container="container7",namespac
UID: "abc-123-xxx",
},
Spec: v1.PodSpec{
NodeName: "node1",
NodeName: "node1",
PriorityClassName: "system-node-critical",
},
Status: v1.PodStatus{
HostIP: "1.1.1.1",
Expand All @@ -579,7 +580,7 @@ kube_pod_container_status_last_terminated_reason{container="container7",namespac
// TODO: Should it be '1501569018' instead?
Want: `
kube_pod_created{namespace="ns1",pod="pod1"} 1.5e+09
kube_pod_info{created_by_kind="<none>",created_by_name="<none>",host_ip="1.1.1.1",namespace="ns1",node="node1",pod="pod1",pod_ip="1.2.3.4",uid="abc-123-xxx"} 1
kube_pod_info{created_by_kind="<none>",created_by_name="<none>",host_ip="1.1.1.1",namespace="ns1",node="node1",pod="pod1",pod_ip="1.2.3.4",uid="abc-123-xxx",priority_class="system-node-critical"} 1
kube_pod_start_time{namespace="ns1",pod="pod1"} 1.501569018e+09
kube_pod_owner{namespace="ns1",owner_is_controller="<none>",owner_kind="<none>",owner_name="<none>",pod="pod1"} 1
`,
Expand Down Expand Up @@ -649,7 +650,7 @@ kube_pod_container_status_last_terminated_reason{container="container7",namespac
},
},
Want: metadata + `
kube_pod_info{created_by_kind="ReplicaSet",created_by_name="rs-name",host_ip="1.1.1.1",namespace="ns2",node="node2",pod="pod2",pod_ip="2.3.4.5",uid="abc-456-xxx"} 1
kube_pod_info{created_by_kind="ReplicaSet",created_by_name="rs-name",host_ip="1.1.1.1",namespace="ns2",node="node2",pod="pod2",pod_ip="2.3.4.5",uid="abc-456-xxx",priority_class=""} 1
kube_pod_completion_time{namespace="ns2",pod="pod2"} 1.501888018e+09
kube_pod_owner{namespace="ns2",owner_is_controller="true",owner_kind="ReplicaSet",owner_name="rs-name",pod="pod2"} 1
`,
Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func TestFullScrapeCycle(t *testing.T) {

expected := `# HELP kube_pod_info Information about pod.
# TYPE kube_pod_info gauge
kube_pod_info{namespace="default",pod="pod0",host_ip="1.1.1.1",pod_ip="1.2.3.4",uid="abc-123-xxx",node="node1",created_by_kind="<none>",created_by_name="<none>"} 1
kube_pod_info{namespace="default",pod="pod0",host_ip="1.1.1.1",pod_ip="1.2.3.4",uid="abc-123-xxx",node="node1",created_by_kind="<none>",created_by_name="<none>",priority_class=""} 1
# HELP kube_pod_start_time Start time in unix timestamp for a pod.
# TYPE kube_pod_start_time gauge
# HELP kube_pod_completion_time Completion time in unix timestamp for a pod.
Expand Down

0 comments on commit 64b70f5

Please sign in to comment.