observability: fix dropped kubelet/cadvisor metrics, add kube-state-metrics + VMAlert k8s.rules #399
Reference in New Issue
Block a user
Delete Branch "benvin/vm-k8s-metrics"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
Kubernetes container metrics are entirely missing from VictoriaMetrics, leaving the CNPG dashboard CPU panels empty. The
kubernetes-nodes/kubernetes-nodes-cadvisorscrape jobs use a blanketlabelmapon__meta_kubernetes_node_label_(.+), copying ~50+ node-feature-discovery labels onto every series; every kubelet/cadvisor series then exceeds vminsert's 40-label default and 100% are silently dropped (vm_rows_ignored_total{reason="too_many_labels"}~38B). On top of that, kube-state-metrics, VMAlert and the kube-prometheusk8s.rulesrecording rules were never deployed, sonode_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate(and companions) have no producer.Changes
labelmapin both node scrape jobs with a single__meta_kubernetes_node_name -> noderelabeljob="kubelet"plusmetrics_path(/metricsand/metrics/cadvisor), matching kube-prometheus selectors; the cadvisor job keeps a distinctjob_name(uniqueness requirement) and forcesjob=kubeletvia relabeljobLabelyieldingjob="kube-state-metrics"), image routed through the artifactapik8s-registryremotenotifier.blackholesince it only evaluates recording rules)k8s.rulesrecording group (cpu sum_irate, memory working_set/rss/cache/swap, namespace requests/limits sums,kube_pod_ownerworkload relabel rules)Prerequisite
The artifactapi
k8s-registryremote exists but itspatternsallowlist (^autoscaling/vpa-,^external-dns/,^sig-storage/) does not coverkube-state-metrics/— terraform-artifactapi needs^kube-state-metrics/added toconfig/remote_docker/k8s-registry.yamlbefore/with this merge, or the KSM pod will ImagePullBackOff.Notes
kustomize build(base + au-syd1 overlay) and kubeconform (VM CRD schemas skipped)