-
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
kubernetes input plugin #569
Comments
@jchauncey How are you monitoring the kubernetes deployment? I've recently overhauled the docker plugin to gather more metrics and allow specifying an endpoint, does this help? https://github.com/influxdata/telegraf/tree/master/plugins/inputs/docker I'm not sure how kubernetes labels work, but the docker labels are applied as tags |
youll need to contact the kube api server to gather the information about each pod and the metrics its consuming. This would be so I could monitor the k8s deployment. My goal is to supplant cadvisor with telegraf to have a tighter integration with influx. |
My thought right now is that when you collect the metrics on the container if they have turned on k8s metrics we reach out to the api server and fetch all the pod information. That would probably take place around here |
Hi @jchauncey, This is slightly out of scope of this issue but for my k8s cluster in production I use both heapster running with InfluxDB sink and telegraf using prometheus input plugin to fetch kubelet metrics. This works pretty well. I'm happy to provide more informations if you want. |
So right now Id like to not rely on heapster and just use the TICK stack as a pure installation on top of k8s. I feel this would ultimately be more powerful than how the cadvisor+heapster stack is being managed. Especially since TICK will move faster than both of those (cadvisor + heapster) |
@sparrc is there a way to decorate data that has been generated in another plugin? I'm trying to decide if polluting the docker plugin with k8s is the right way to go or not. |
I think making a separate kubernetes plugin would be better. It's okay if there is some duplicated docker code. Or you could also break out the docker metric collection into a separate package and put it in |
@sparrc is there a reason you used |
@jchauncey not particularly.......I'm not opposed to changing it to |
k ill probably make that change as part of my refactor to support the k8s plugin. |
fixes influxdata#569 This commit also refactors the existing docker plugin so that the kubernetes plugin can gather metrics from the docker system.
fixes influxdata#569 This commit also refactors the existing docker plugin so that the kubernetes plugin can gather metrics from the docker system.
fixes influxdata#569 This commit also refactors the existing docker plugin so that the kubernetes plugin can gather metrics from the docker system.
fixes influxdata#569 This commit also refactors the existing docker plugin so that the kubernetes plugin can gather metrics from the docker system.
@sparrc can you do token replacements in the toml file? For example if I do:
will it do the right thing? |
I don't think that's part of the toml spec, so probably not |
fixes influxdata#569 This commit also refactors the existing docker plugin so that the kubernetes plugin can gather metrics from the docker system.
fixes influxdata#569 This commit also refactors the existing docker plugin so that the kubernetes plugin can gather metrics from the docker system.
@sparrc so ive been trying to strip out the kubernetes api from the main repo and reduce the number of dependencies. however, it doesnt seem to be helping. No matter what I try I cant get the binary below 54 megs. outside of writing a brand new client im not sure what i can do to help |
hah it closed this issue because I merged my PR into the deis org. Anyways for now I am going to maintain my own fork of telegraf with the k8s plugin since I cannot seem to reduce the binary size. If you decide that you are ok with the binary size I'll resubmit the PR. |
So I found this go project called goupx which reduced the binary size of telegraf (with the kubernetes deps) to 12M.
|
@rvrignaud I would love to hear about how you're using Heapster (with InfluxDB sink) together with Telegraf's Prometheus plugin for kubelet metrics. What does the basic data-flow and setup look like? Thanks for any insight! |
Also, the Docker containers started by the kubelet contain Docker labels for several pieces of kubernetes metadata. See kubernetes/kubernetes#17234 for some details. It looks like k8s container name, pod name, namespace and some other (static) metadata is attached as labels on container startup. If it covers the desired tag values, this may be easier (and more efficient) that going out to the k8s apiserver for pod details. |
There is also a contributor who is making improvements to the prometheus plugin to allow it to collect kubernetes metrics: #707 |
I don't think k8s current applies pod labels to the docker label structure. There are a few items in the docker labels but I don't think pod namespace nor pod name are in that list. It definitely doesn't contain pod labels set via the manifest. That could change in future releases. |
👍 definitely waiting for this to get merged in |
Hi @emmanuel, Not sure to understand what you are looking for, but here is what I have:
|
@emmanuel @jchauncey I'm agree with @rvrignaud ! I think the best think to do is to use Heapster to get container metrics and use Prometheus input plugin to get k8s (infrastructure) metrics from kube-apiserver/kube-scheduler/kube-controller-manager/kubelet. |
So I agree completely and have already got work planned starting this week
|
So I have a branch which has fixed the prometheus plugin to have the necessary bits to talk to the kubernetes cluster - https://github.com/jchauncey/telegraf/tree/prometheus I am going to test this locally for a bit before I submit a PR but I think it will work well for everyone. |
@jchauncey I made a PR for the prometheus plugin here: #707 |
Sure we thats fine. Really all we need is the ability to pass the bearer token in the http request. |
@jchauncey Could you copy/paste an example of Prometheus input plugin config for kubernetes ? |
yup working on that now =) |
@titilambert https://gist.github.com/jchauncey/18f3615d035fdbda141f That includes my changes to your PR to have prometheus talk to kubernetes. It also includes a manifest for how to start the daemon (the image provided is using my PR). I also have a special toml go template that I use to go from env vars to the values in the config.toml.
|
My one problem right now is that by running telegraf in a container the hostname reported is the container's hostname which is wrong. I would rather it be the node hostname (especially for host level metrics). |
BTW, I didn't get why you need your patch. I already can get data from my Kube-service: http://apiserver:8080/metrics |
that doesnt work if your api server requires ssl |
Datadog has a similar issue and I resolved it for us like so DataDog/docker-dd-agent#67 however this is only valid for AWS environments. I did however create another tool that uses kubectl and this very hostname to determine what node it is running on https://github.com/Vungle/labelgun/blob/master/labelgun.go#L26 you could use the same logic. |
@jchauncey OK ! |
no i want to collect host level metrics (cadvisor doesnt actually expose that many) by mounting in |
Does this container run on kubernetes ? Or just as a simple docker container ? |
it runs on kubernetes as a daemonset |
OK ! |
@titilambert like this -
That works and sets the correct hostname so thanks for the suggestion |
@titilambert I am having pretty good success with your PR combined with my change for the bearer token. Let me know when your PR gets merged. |
@jchauncey maybe we should create a folder (in telegraf repo) for Prometheus for store application example (like kubernetes/etcd/...) |
Hi @jchauncey and @titilambert , You shouldn't have to do your trick to get the right hostname using a configuration like:
I think this is hostNetwork that allow to get real hostname inside the pod but that needs to be checked. My 2 cents |
@rvrignaud Thanks ! |
That binds the pod to the host network interface which most users dont want
|
@sparrc Doing a bit of house keeping on old issues ive opened and found this one. We can probably close it now that we have an input plugin in master. |
It would be nice to see telegraf support kuberentes deployments. This means decorating metrics with appropriate pod labels (pod name, namespace, container name, etc..).
I'll try and take a stab at this soon as I would like to use telegraf instead of cadvisor for collecting metrics on my k8s cluster.
The text was updated successfully, but these errors were encountered: