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

kromogo cluster_age_days calculation #6940

Closed
reefland opened this issue Feb 10, 2024 · 1 comment
Closed

kromogo cluster_age_days calculation #6940

reefland opened this issue Feb 10, 2024 · 1 comment

Comments

@reefland
Copy link

I think you have the wrong calculation for cluster_age_days using:

          - name: cluster_age_days
            query: round((time() - max(kube_node_created{kubernetes_node=~"k8s-[0-9]+"}) ) / 86400)
            suffix: "d"

The max(kube_node_created) would return the value of your newest node member, not your oldest. Thus it returns the number of days since you last added a node. If you want the cluster age in days, then use the min() to get the timestamp of the oldest cluster node.

When I use round((time() - min(kube_node_created)) / 86400) I get 681 which lines up to the age of my oldest cluster node:

$ k get nodes
NAME    STATUS   ROLES                       AGE    VERSION
k3s01   Ready    control-plane,etcd,master   680d   v1.28.5+k3s1
k3s02   Ready    control-plane,etcd,master   654d   v1.28.5+k3s1
k3s03   Ready    control-plane,etcd,master   661d   v1.28.5+k3s1
k3s04   Ready    worker                      427d   v1.28.5+k3s1
k3s05   Ready    worker                      427d   v1.28.5+k3s1
k3s06   Ready    worker                      354d   v1.28.5+k3s1

if I use max() then I get 355 which is the age of the newest node.

@onedr0p
Copy link
Owner

onedr0p commented Feb 11, 2024

Thanks for reporting, fixed!

@onedr0p onedr0p closed this as completed Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants