Telegraf for kubernetes pods/containers

Hi,

I’d like to collect metrics with telegraf of the kubernetes pods that I have.
I found this article, but this is not really for pods.
Can you please help me how I can collect metrics with telegraf of the running pods? Is there any documentation or anything that I can follow and set it up?

Regards,
B

Check out the kube_inventory plugin.

Any idea how can I use that ones?
When I list the input plugins, it is in the input list:
kube_inventory
kubernetes

But this url thing make me confused. I have to add the url of the api and it will read all the data?

Hi @Badb0y ,

you will have to replace the url in the telegraf config with your url
and uncomment the following 2 lines ,
then it will read the data

[[inputs.kube_inventory]]
url = “https://127.0.0.1

# # Read metrics from the Kubernetes api
# [[inputs.kube_inventory]]
#   ## URL for the Kubernetes API
#   url = "https://127.0.0.1" 
#
#   ## Namespace to use. Set to "" to use all namespaces.
#   # namespace = "default"

What I’ve done, I add this plugin (I tried the inventory as well but this one can suit my need better)

[[inputs.kubernetes]]
url = “https://192.168.213.18:6443

I have errors in the log like this:

May 6 23:49:00 k8s-master infra-telegraf: 2019-05-07T03:49:00Z E! [inputs.kube_inventory]: Error in plugin: performing request: Get https://192.168.213.18/api/v1/namespaces/default/pods: dial tcp 192.168.213.18:443: connect: connection refused
May 6 23:49:00 k8s-master infra-telegraf: 2019-05-07T03:49:00Z E! [inputs.kube_inventory]: Error in plugin: performing request: Get https://192.168.213.18/api/v1/persistentvolumes: dial tcp 192.168.213.18:443: connect: connection refused
May 6 23:49:00 k8s-master infra-telegraf: 2019-05-07T03:49:00Z E! [inputs.kube_inventory]: Error in plugin: performing request: Get https://192.168.213.18/api/v1/nodes: dial tcp 192.168.213.18:443: connect: connection refused
May 6 23:49:00 k8s-master infra-telegraf: 2019-05-07T03:49:00Z E! [inputs.kube_inventory]: Error in plugin: performing request: Get https://192.168.213.18/apis/apps/v1beta1/namespaces/default/deployments: dial tcp 192.168.213.18:443: connect: connection refused
May 6 23:49:00 k8s-master infra-telegraf: 2019-05-07T03:49:00Z E! [inputs.kubernetes]: Error in plugin: error making HTTP request to https://192.168.213.18:6443/stats/summary: x509: certificate signed by unknown authority

I haven’t set any special CA things, I’ve tried to add the certs from the /etc/kubernetes/pki/ directory, but didn’t work (might be I set wrong ones)

I’ve installed a standalone telegraf rpm, but in the description they mention it should run as daemonset.
Unusable deployment guide

Can this work without daemonset setup?

If not is there any option how to deploy telegraf as a daemonset which is usable?

Regarding the cert issues, have you tried setting insecure_skip_verify = true in the config for your tests?

The connection refused being logged by the kube_inventory plugin seems to be an incorrectly configured url.

Yeah, didn’t help.
So can we use the rpm based telegraf on a kubernetes cluster with the kubernetes inputs without running as a daemonset? It has to work without daemonset things?