Skip to content

Commit

Permalink
Merge pull request kubernetes#1890 from rexagod/1889
Browse files Browse the repository at this point in the history
Add node deletionTimestamp metric
  • Loading branch information
k8s-ci-robot authored Nov 16, 2022
2 parents b2c90e8 + ed551af commit 53a0dc6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/node-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
| kube_node_status_allocatable | Gauge | The allocatable for different resources of a node that are available for scheduling | `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 |
| 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 |
| kube_node_created | Gauge | Unix creation timestamp | seconds |`node`=&lt;node-address&gt;| STABLE |
| kube_node_deletion_timestamp | Gauge | Unix creation timestamp | seconds |`node`=&lt;node-address&gt;| STABLE |
26 changes: 25 additions & 1 deletion internal/store/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ var (

func nodeMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator {
return []generator.FamilyGenerator{
createNodeAnnotationsGenerator(allowAnnotationsList),
createNodeCreatedFamilyGenerator(),
createNodeDeletionTimestampFamilyGenerator(),
createNodeInfoFamilyGenerator(),
createNodeAnnotationsGenerator(allowAnnotationsList),
createNodeLabelsGenerator(allowLabelsList),
createNodeRoleFamilyGenerator(),
createNodeSpecTaintFamilyGenerator(),
Expand All @@ -57,6 +58,29 @@ func nodeMetricFamilies(allowAnnotationsList, allowLabelsList []string) []genera
}
}

func createNodeDeletionTimestampFamilyGenerator() generator.FamilyGenerator {
return *generator.NewFamilyGeneratorWithStability(
"kube_node_deletion_timestamp",
"Unix deletion timestamp",
metric.Gauge,
basemetrics.ALPHA,
"",
wrapNodeFunc(func(n *v1.Node) *metric.Family {
var ms []*metric.Metric

if n.DeletionTimestamp != nil && !n.DeletionTimestamp.IsZero() {
ms = append(ms, &metric.Metric{
Value: float64(n.DeletionTimestamp.Unix()),
})
}

return &metric.Family{
Metrics: ms,
}
}),
)
}

func createNodeCreatedFamilyGenerator() generator.FamilyGenerator {
return *generator.NewFamilyGeneratorWithStability(
"kube_node_created",
Expand Down

0 comments on commit 53a0dc6

Please sign in to comment.