Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add node deletionTimestamp metric #1890

Merged
merged 1 commit into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to set this metric as Alpha/Experimental first, and then promote this into Stable?

Because, labels/metric name can't be changed if it's a stable metric.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! @rexagod can you introduce it as experimental?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK, fixed.

"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