-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
fix: prometheus input plugin run outside k8s cluster error #11673
fix: prometheus input plugin run outside k8s cluster error #11673
Conversation
3eceac2
to
c51bc9c
Compare
Hi, Can you remind me if you filed a bug for this issue? Also, I understand the only way to try to start monitoring a K8s cluster is if Thanks |
In this case such as following input config,the telegraf process is not running properly [[inputs.prometheus]]
monitor_kubernetes_pods = true
kube_config = "/path/to/kubernetes.config" |
In my environment, telegraf is running outside the k8s cluster, so I need to specify kubeconfig to run telegraf, and then I get an error. After analyzing the prometheus input plugin code, I found that the problem occurs in the following two points:
|
c51bc9c
to
a33c07d
Compare
Download PR build artifacts for linux_amd64.tar.gz, darwin_amd64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
Hi @powersj would you please help me to review this pr once again? |
Required for all PRs
resolves #
The first one, when we run telegra in outside of a kubernetes cluster the line
config, err := rest.InClusterConfig()
will be always get an error.The second one, the method of getting rest.Config instance in loadClient function will be cause kubernetes client has error materURL, and this error can be reproduced by using the following UT:
this UT can got watch pod got err: Get "http://localhost/api/v1/namespaces/kube-system/pods?labelSelector=app%3Ddebug&watch=true": dial tcp 127.0.0.1:80: connect: connection refused error.