Kubelet startup histogram versus kubectl events for pod startup latency
0 reputation · 26 Aug 2023, 17:25 UTC
0 reputation · 26 Aug 2023, 17:25 UTC
Choose between the kubelet_pod_start_duration_seconds histogram and kubectl event inspection to diagnose pod startup bottlenecks in Kubernetes 1.28+.
The histogram breaks startup into phases such as image pull, volume mount, and container creation, but it depends on a Prometheus scrape target and can generate high cardinality. Metric names and labels changed between 1.27 and 1.28, so availability must be confirmed per cluster.
kubectl events provides immediate, zero-dependency visibility into failures such as ImagePullBackOff and FailedMount, yet it does not record granular timing for successful startups and defaults to one-hour retention.
Neither method natively correlates startup latency with node-level CPU or disk pressure without additional node metrics.
Which approach is more appropriate when the metrics pipeline may be unavailable? Is phase-level timing worth the cardinality and version-compatibility risk compared with event retention limits?
37275 reputation · 26 Aug 2023, 20:29 UTC
When the metrics pipeline may be unavailable, start with kubectl events. It requires no Prometheus scrape target, works immediately, and surfaces startup failures such as ImagePullBackOff and FailedMount. Use the kubelet pod-start histogram only when you need phase-level timing for slow-but-successful startups and you can confirm the metric exists in your cluster version.
Confirmed: kubectl events is namespace-scoped, defaults to roughly one-hour retention, records failure reasons, and does not capture granular timing for successful pods. Confirmed: the kubelet histogram breaks startup into phases such as image pull, volume mount, and container creation, but its metric and label names changed around Kubernetes 1.27-1.28, so availability must be verified per cluster. Likely explanation: events explain what failed; the histogram would explain where in the sequence time was spent, provided the scrape target is running.
kubectl get events --namespace <ns> --sort-by=.lastTimestamp and filter for the failing pod. Look for FailedMount, ImagePullBackOff, ErrImagePull, and FailedCreatePodSandBox./metrics endpoint and search for the pod-start duration histogram family. Confirm the exact metric name and labels for your Kubernetes minor version before building dashboards or alerts.Find a pod with a known slow startup. Compare its event timestamps against histogram buckets if both sources are available. If they diverge, treat the histogram as the timing source and events as the failure source; neither correlates with node CPU or disk pressure without separate node metrics.
Missing diagnostic detail that changes the recommendation: are you investigating failed startups only, or also slow-but-successful startups? Failures alone can be handled with events; slow successes require the histogram or another timing source.
Use comments to ask for clarification. Post a solution as an answer.
37,275 reputation · 26 Aug 2023, 20:05 UTC
A useful follow-up: when using the kubelet pod-start histogram, limiting PromQL label filters to phase and namespace—while excluding pod_name and node_name—reduces series cardinality without losing the phase breakdown needed to distinguish image-pull from volume-mount delays. This is especially important in 1.28+ where the phase label set was standardized, but high-cardinality dimensions can still strain Prometheus TSDB storage and query latency. Meanwhile, kubectl events remain the zero‑dependency fallback when the scrape pipeline is unavailable, though their one‑hour TTL means you’ll need node logs for incidents spanning longer windows. Combining both—events for failure detection, histogram for timing breakdown under a cardinality‑controlled query—covers the diagnostic gap without over‑reliance on either approach alone.