Skip to content

Add semconv for k8s node condition as metric #2321

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ChrsMark
Copy link
Member

@ChrsMark ChrsMark commented Jun 4, 2025

Fixes #2077

Changes

This PR adds the k8s.node.condition metric

Merge requirement checklist

@ChrsMark ChrsMark requested review from a team as code owners June 4, 2025 08:57
@github-actions github-actions bot added enhancement New feature or request area:k8s labels Jun 4, 2025
@lmolkova lmolkova moved this from Untriaged to Awaiting SIG approval in Semantic Conventions Triage Jun 4, 2025
brief: |
The node is healthy and ready to accept pods. and Unknown if the node controller has not heard from the node in the last node-monitor-grace-period"
stability: development
- id: ready_unknown
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem to be listed in node conditions. Is this just because it is the only condition that can be unknown in addition to t/f?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, but we can avoid this by using the k8s.condition.status with values T/F/unknown. Should be fixed by
34f1e08.

Also, note that beyond these listed conditions there might other custom ones defined. So it's safer to have the option to track unknown status properly.

@@ -434,6 +434,43 @@ groups:
value: 'terminating'
brief: "Terminating namespace phase as described by [K8s API](https://pkg.go.dev/k8s.io/[email protected]/core/v1#NamespacePhase)"
stability: development
- id: k8s.node.condition
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we consider using k8s.condition.type and k8s.condition.status (without node/pod namespace)? I know technically all of the XXXCondition types are separate, but they all follow the same type/status/reason pattern.

Copy link
Member Author

Choose a reason for hiding this comment

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

What values would k8s.condition.status and k8s.condition.type accept?

Copy link
Contributor

Choose a reason for hiding this comment

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

Status would have T/F/unknown. Type would be open-ended, but we could provide examples from common objects

Copy link
Member Author

Choose a reason for hiding this comment

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

I see!

It seems kube-state-metrics follows the same pattern here: https://github.com/kubernetes/kube-state-metrics/blob/v2.15.0/docs/metrics/cluster/node-metrics.md?plain=1#L14

I will change it like this 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, does KSM have reason as a label? That seems like it would be useful, although it is somewhat higher cardinality

Copy link
Member Author

@ChrsMark ChrsMark Jun 5, 2025

Choose a reason for hiding this comment

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

There are some reason labels for containers' and Pods' statuses but not for Node's conditions: https://github.com/kubernetes/kube-state-metrics/blob/v2.15.0/docs/metrics/workload/pod-metrics.md

For containers' status we have it already in SemConv: https://github.com/open-telemetry/semantic-conventions/blob/main/model/k8s/metrics.yaml#L80

Copy link
Contributor

Choose a reason for hiding this comment

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

I would lean towards adding it, but if we are unsure, we can always do that later.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea! I have added it.

The modeling of this metric is becoming a bit tricky because we have to ensure that metric's name does not collide with a namespace. k8s.node.condition cannot be the metric name and a namespace for the attributes at the same time. Let me know what you think about the current suggestion.

@ChrsMark ChrsMark moved this to In Review in K8s SemConv SIG Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:k8s enhancement New feature or request
Projects
Status: In Review
Status: Awaiting SIG approval
Development

Successfully merging this pull request may close these issues.

[k8s] Define semantic conventions for k8s node condition metric
2 participants