Skip to content

Commit 59b1728

Browse files
author
Ryan R. Olds
committed
Merge branch 'main' into rolds/pod_ready_time
2 parents dd7202b + 559bb28 commit 59b1728

File tree

6 files changed

+69
-3
lines changed

6 files changed

+69
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ are deleted they are no longer visible on the `/metrics` endpoint.
4747
- [Resource recommendation](#resource-recommendation)
4848
- [Horizontal sharding](#horizontal-sharding)
4949
- [Automated sharding](#automated-sharding)
50-
- [Daemonset sharding for pod metrics](#daemonset-sharding-pod-metrics)
50+
- [Daemonset sharding for pod metrics](#daemonset-sharding-for-pod-metrics)
5151
- [Setup](#setup)
5252
- [Building the Docker container](#building-the-docker-container)
5353
- [Usage](#usage)

docs/node-metrics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
| kube_node_status_allocatable | Gauge | The amount of resources allocatable for pods (after reserving some for system daemons) | `cpu`=&lt;core&gt; <br> `ephemeral_storage`=&lt;byte&gt; <br> `pods`=&lt;integer&gt; <br> `attachable_volumes_*`=&lt;byte&gt; <br> `hugepages_*`=&lt;byte&gt; <br> `memory`=&lt;byte&gt; |`node`=&lt;node-address&gt; <br> `resource`=&lt;resource-name&gt; <br> `unit`=&lt;resource-unit&gt;| STABLE |
1313
| kube_node_status_condition | Gauge | The condition of a cluster node | |`node`=&lt;node-address&gt; <br> `condition`=&lt;node-condition&gt; <br> `status`=&lt;true\|false\|unknown&gt; | STABLE |
1414
| kube_node_created | Gauge | Unix creation timestamp | seconds |`node`=&lt;node-address&gt;| STABLE |
15-
| kube_node_deletion_timestamp | Gauge | Unix creation timestamp | seconds |`node`=&lt;node-address&gt;| EXPERIMENTAL |
15+
| kube_node_deletion_timestamp | Gauge | Unix deletion timestamp | seconds |`node`=&lt;node-address&gt;| EXPERIMENTAL |

docs/pod-metrics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
| kube_pod_labels | Gauge | Kubernetes labels converted to Prometheus labels | | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `label_POD_LABEL`=&lt;POD_LABEL&gt; <br> `uid`=&lt;pod-uid&gt; | STABLE | - |
1212
| kube_pod_nodeselectors| Gauge | Describes the Pod nodeSelectors | | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `nodeselector_NODE_SELECTOR`=&lt;NODE_SELECTOR&gt; <br> `uid`=&lt;pod-uid&gt; | EXPERIMENTAL | Opt-in |
1313
| kube_pod_status_phase | Gauge | The pods current phase | | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `phase`=&lt;Pending\|Running\|Succeeded\|Failed\|Unknown&gt; <br> `uid`=&lt;pod-uid&gt; | STABLE | - |
14+
| kube_pod_status_qos_class | Gauge | The pods current qosClass | | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `qos_class`=&lt;BestEffort\|Burstable\|Guaranteed&gt; <br> `uid`=&lt;pod-uid&gt; | EXPERIMENTAL | - |
1415
| kube_pod_status_ready | Gauge | Describes whether the pod is ready to serve requests | | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `condition`=&lt;true\|false\|unknown&gt; <br> `uid`=&lt;pod-uid&gt; | STABLE | - |
1516
| kube_pod_status_scheduled | Gauge | Describes the status of the scheduling process for the pod | |`pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `condition`=&lt;true\|false\|unknown&gt; <br> `uid`=&lt;pod-uid&gt; | STABLE | - |
1617
| kube_pod_container_info | Gauge | Information about a container in a pod | | `container`=&lt;container-name&gt; <br> `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `image`=&lt;image-name&gt; <br> `image_id`=&lt;image-id&gt; <br> `image_spec`=&lt;image-spec&gt; <br> `container_id`=&lt;containerid&gt; <br> `uid`=&lt;pod-uid&gt; | STABLE | - |

internal/store/pod.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ func podMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat
8282
createPodSpecVolumesPersistentVolumeClaimsReadonlyFamilyGenerator(),
8383
createPodStartTimeFamilyGenerator(),
8484
createPodStatusPhaseFamilyGenerator(),
85+
createPodStatusQosClassFamilyGenerator(),
8586
createPodStatusReadyFamilyGenerator(),
8687
createPodStatusReadyTimeFamilyGenerator(),
8788
createPodStatusContainerReadyTimeFamilyGenerator(),
@@ -1373,6 +1374,48 @@ func createPodStatusReadyTimeFamilyGenerator() generator.FamilyGenerator {
13731374
)
13741375
}
13751376

1377+
func createPodStatusQosClassFamilyGenerator() generator.FamilyGenerator {
1378+
return *generator.NewFamilyGeneratorWithStability(
1379+
"kube_pod_status_qos_class",
1380+
"The pods current qosClass.",
1381+
metric.Gauge,
1382+
basemetrics.ALPHA,
1383+
"",
1384+
wrapPodFunc(func(p *v1.Pod) *metric.Family {
1385+
class := p.Status.QOSClass
1386+
if class == "" {
1387+
return &metric.Family{
1388+
Metrics: []*metric.Metric{},
1389+
}
1390+
}
1391+
1392+
qosClasses := []struct {
1393+
v bool
1394+
n string
1395+
}{
1396+
{class == v1.PodQOSBestEffort, string(v1.PodQOSBestEffort)},
1397+
{class == v1.PodQOSBurstable, string(v1.PodQOSBurstable)},
1398+
{class == v1.PodQOSGuaranteed, string(v1.PodQOSGuaranteed)},
1399+
}
1400+
1401+
ms := make([]*metric.Metric, len(qosClasses))
1402+
1403+
for i, p := range qosClasses {
1404+
ms[i] = &metric.Metric{
1405+
1406+
LabelKeys: []string{"qos_class"},
1407+
LabelValues: []string{p.n},
1408+
Value: boolFloat64(p.v),
1409+
}
1410+
}
1411+
1412+
return &metric.Family{
1413+
Metrics: ms,
1414+
}
1415+
}),
1416+
)
1417+
}
1418+
13761419
func createPodStatusReadyFamilyGenerator() generator.FamilyGenerator {
13771420
return *generator.NewFamilyGeneratorWithStability(
13781421
"kube_pod_status_ready",

internal/store/pod_test.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,26 @@ func TestPodStore(t *testing.T) {
12941294
`,
12951295
MetricNames: []string{"kube_pod_status_phase", "kube_pod_status_reason"},
12961296
},
1297+
{
1298+
Obj: &v1.Pod{
1299+
ObjectMeta: metav1.ObjectMeta{
1300+
Name: "pod1",
1301+
Namespace: "ns1",
1302+
UID: "uid1",
1303+
},
1304+
Status: v1.PodStatus{
1305+
QOSClass: v1.PodQOSBestEffort,
1306+
},
1307+
},
1308+
Want: `
1309+
# HELP kube_pod_status_qos_class The pods current qosClass.
1310+
# TYPE kube_pod_status_qos_class gauge
1311+
kube_pod_status_qos_class{namespace="ns1",qos_class="BestEffort",pod="pod1",uid="uid1"} 1
1312+
kube_pod_status_qos_class{namespace="ns1",qos_class="Burstable",pod="pod1",uid="uid1"} 0
1313+
kube_pod_status_qos_class{namespace="ns1",qos_class="Guaranteed",pod="pod1",uid="uid1"} 0
1314+
`,
1315+
MetricNames: []string{"kube_pod_status_qos_class"},
1316+
},
12971317
{
12981318
Obj: &v1.Pod{
12991319
ObjectMeta: metav1.ObjectMeta{
@@ -2091,7 +2111,7 @@ func BenchmarkPodStore(b *testing.B) {
20912111
},
20922112
}
20932113

2094-
expectedFamilies := 49
2114+
expectedFamilies := 50
20952115
for n := 0; n < b.N; n++ {
20962116
families := f(pod)
20972117
if len(families) != expectedFamilies {

pkg/app/server_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ func TestFullScrapeCycle(t *testing.T) {
239239
# HELP kube_pod_spec_volumes_persistentvolumeclaims_readonly [STABLE] Describes whether a persistentvolumeclaim is mounted read only.
240240
# HELP kube_pod_start_time [STABLE] Start time in unix timestamp for a pod.
241241
# HELP kube_pod_status_container_ready_time Readiness achieved time in unix timestamp for a pod containers.
242+
# HELP kube_pod_status_qos_class The pods current qosClass.
242243
# HELP kube_pod_status_phase [STABLE] The pods current phase.
243244
# HELP kube_pod_status_ready_time Readiness achieved time in unix timestamp for a pod.
244245
# HELP kube_pod_status_ready [STABLE] Describes whether the pod is ready to serve requests.
@@ -288,6 +289,7 @@ func TestFullScrapeCycle(t *testing.T) {
288289
# TYPE kube_pod_start_time gauge
289290
# TYPE kube_pod_status_container_ready_time gauge
290291
# TYPE kube_pod_status_phase gauge
292+
# TYPE kube_pod_status_qos_class gauge
291293
# TYPE kube_pod_status_ready gauge
292294
# TYPE kube_pod_status_ready_time gauge
293295
# TYPE kube_pod_status_reason gauge

0 commit comments

Comments
 (0)