google / cadvisor

Analyzes resource usage and performance characteristics of running containers.
Other
16.92k stars 2.31k forks source link

how to export cadvisor metrics to the external Prometheus server? #2662

Closed pharthiphan closed 4 years ago

pharthiphan commented 4 years ago

how to export cadvisor metrics to the external Prometheus server?

I have cadvisor deployed on the k8s cluster

~/kustomize build deploy/kubernetes/overlays/examples_perf | kubectl apply -f -

` kubectl get all -o wide -n cadvisor NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES pod/cadvisor-b2zl5 1/1 Running 0 29m 10.244.3.12 sn86 pod/cadvisor-chk77 1/1 Running 0 29m 10.244.6.9 sn83 pod/cadvisor-crqph 1/1 Running 0 29m 10.244.2.13 sn102 pod/cadvisor-rmlnd 1/1 Running 0 29m 10.244.4.11 sn58

NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE CONTAINERS IMAGES SELECTOR daemonset.apps/cadvisor 4 4 4 4 4 85m cadvisor gcr.io/cadvisor/cadvisor:v0.37.0 app=cadvisor,name=cadvisor `

for the kube-state-metrics, I have forwarded the port of the kube-state-metrics locally and used it on the Prometheus config.

but not sure how to do that cadvisor!

wacuuu commented 4 years ago

The easiest way is to add

hostNetwork: true

to pod spec. This will bind port 8080 exposed by daemonset.yaml to host. Then you should be able to scrap the data just by putting host ip and the 8080 port to scrap config.

pharthiphan commented 4 years ago

Thank you, that helped

SiramShankaran commented 2 months ago

can we use different port ? ex. port 8082