kube-state-metrics: kube-state-metrics - write: broken pipe
What happened: After noticing some “anomaliles” in some metrics, did a little Googling and checked the kube-state-metrics pod log. Found numerous messages like the following:
E1205 05:04:35.900320 1 metrics_handler.go:223] "Failed to write EOF directive" err="write tcp 10.244.42.152:8080->10.244.101.147:35432: write: broken pipe"
E1205 05:05:37.269362 1 metrics_handler.go:215] "Failed to write metrics" err="failed to write metrics family: write tcp 10.244.42.152:8080->10.244.101.147:40672: write: broken pipe"
E1205 05:05:37.269391 1 metrics_handler.go:215] "Failed to write metrics" err="failed to write help text: write tcp 10.244.42.152:8080->10.244.101.147:40672: write: broken pipe"
E1205 05:05:37.269401 1 metrics_handler.go:215] "Failed to write metrics" err="failed to write help text: write tcp 10.244.42.152:8080->10.244.101.147:40672: write: broken pipe"
E1205 05:05:37.269410 1 metrics_handler.go:215] "Failed to write metrics" err="failed to write help text: write tcp 10.244.42.152:8080->10.244.101.147:40672: write: broken pipe"
E1205 05:05:37.269418 1 metrics_handler.go:215] "Failed to write metrics" err="failed to write help text: write tcp 10.244.42.152:8080->10.244.101.147:40672: write: broken pipe"
E1205 05:05:37.269425 1 metrics_handler.go:215] "Failed to write metrics" err="failed to write help text: write tcp 10.244.42.152:8080->10.244.101.147:40672: write: broken pipe"
E1205 05:05:37.269434 1 metrics_handler.go:223] "Failed to write EOF directive" err="write tcp 10.244.42.152:8080->10.244.101.147:40672: write: broken pipe"
What you expected to happen: Not really sure, but I am sure these error messages are not good.
How to reproduce it (as minimally and precisely as possible):
I am not sure how to reproduce this, as I don’t know what causes it to occur. I found it in the pod logs, then decided to restart the pod. Unfortunately this blew away the old logs and it has yet to appear in the new pod logs.
Anything else we need to know?:
Environment:
- kube-state-metrics version:
I used the kube-prometheus-stack Helm chart (https://github.com/prometheus-community/helm-charts/) to install Prometheus, Grafana, etc. to our Kubernetes cluster. The Helm chart version is 52.1.0. After inspecting the Helm chart dependencies, I believe kube-state-metrics is version 5.14.0.
I did a quick inspection of the pod spec and found the following:
containers:
- name: kube-state-metrics
image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.10.0
args:
- '--port=8080'
- >-
--resources=certificatesigningrequests,configmaps,cronjobs,daemonsets,deployments,endpoints,horizontalpodautoscalers,ingresses,jobs,leases,limitranges,mutatingwebhookconfigurations,namespaces,networkpolicies,nodes,persistentvolumeclaims,persistentvolumes,poddisruptionbudgets,pods,replicasets,replicationcontrollers,resourcequotas,secrets,services,statefulsets,storageclasses,validatingwebhookconfigurations,volumeattachments
- Kubernetes version (use
kubectl version):
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.0", GitCommit:"c2b5237ccd9c0f1d600d3072634ca66cefdf272f", GitTreeState:"clean", BuildDate:"2021-08-04T18:03:20Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.6", GitCommit:"741c8db18a52787d734cbe4795f0b4ad860906d6", GitTreeState:"clean", BuildDate:"2023-09-13T09:14:09Z", GoVersion:"go1.20.8", Compiler:"gc", Platform:"linux/amd64"}
WARNING: version difference between client (1.22) and server (1.27) exceeds the supported minor version skew of +/-1
- Cloud provider or hardware configuration:
Our K8s cluster is an on-premises installation. The cluster nodes are running Ubuntu 20.04.
- Other info:
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 19
- Comments: 32 (16 by maintainers)
What’s the equivalent of
vmagent parameter promscrape.maxScrapeSizein Prometheus? If it isbody_size_limit, it’s default to 0, which is no limit. I’m still having the same issue, let me know if you folks were able to implement such solution and see results.@CatherineF-dev: Closing this issue.
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
We are also facing this issue in a prometheus setup. It happens only on one out of five clusters, where all 5 clusters are all clusters use the identical setup.
Increasing cpu/memory does not help in our case.
The issue here is that the scrape request from prom to state-metrics takes to long. (~13s) As the default scrape timeout is 10s, prom terminates the connection which leads to the broken pipe in the state metrics pod.
Strangely, when calling the metrics endpoint on state-metrics directly (via port forward) the request only takes 500ms.