Skip to content

Commit

Permalink
pod: add gauge for runtimeclass handler
Browse files Browse the repository at this point in the history
Add a metric gauge to provide observability for the runtimeclass
used for running a pod.

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
  • Loading branch information
egernst committed Oct 23, 2020
1 parent 013d43a commit da18e2d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/pod-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
| kube_pod_container_resource_limits_ephemeral_storage_bytes | Gauge | `container`=&lt;container-name&gt; <br> `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; | EXPERIMENTAL |
| kube_pod_overhead_cpu_cores | Gauge | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; | EXPERIMENTAL |
| kube_pod_overhead_memory_bytes | Gauge | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; | EXPERIMENTAL |
| kube_pod_runtimeclass_handler | Gauge | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; | EXPERIMENTAL |
| kube_pod_created | Gauge | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; | STABLE |
| kube_pod_deletion_timestamp | Gauge | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; | EXPERIMENTAL |
| kube_pod_restart_policy | Gauge | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `type`=&lt;Always|Never|OnFailure&gt; | STABLE |
Expand Down
21 changes: 21 additions & 0 deletions internal/store/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,27 @@ var (
}
}

return &metric.Family{
Metrics: ms,
}
}),
),
*generator.NewFamilyGenerator(
"kube_pod_runtimeclass_handler",
"The runtimeclass handler associated with the pod.",
metric.Gauge,
"",
wrapPodFunc(func(p *v1.Pod) *metric.Family {
ms := []*metric.Metric{}

if p.Spec.RuntimeClassName != nil {
ms = append(ms, &metric.Metric{
LabelKeys: []string{"runtimeclass_handler"},
LabelValues: []string{*p.Spec.RuntimeClassName},
Value: 1,
})
}

return &metric.Family{
Metrics: ms,
}
Expand Down
2 changes: 1 addition & 1 deletion internal/store/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,7 @@ func BenchmarkPodStore(b *testing.B) {
},
}

expectedFamilies := 57
expectedFamilies := 58
for n := 0; n < b.N; n++ {
families := f(pod)
if len(families) != expectedFamilies {
Expand Down
2 changes: 2 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ kube_pod_container_resource_limits{namespace="default",pod="pod0",container="pod
# TYPE kube_pod_overhead_cpu_cores gauge
# HELP kube_pod_overhead_memory_bytes The pod overhead in regards to memory associated with running a pod.
# TYPE kube_pod_overhead_memory_bytes gauge
# HELP kube_pod_runtimeclass_handler The runtimeclass handler associated with the pod.
# TYPE kube_pod_runtimeclass_handler gauge
`

expectedSplit := strings.Split(strings.TrimSpace(expected), "\n")
Expand Down

0 comments on commit da18e2d

Please sign in to comment.