Search code examples
dockercadvisor

How can we collect performance metrics from CAdvisor docker container?


Sorry I just started to learn docker. My question may seem stupid for some of you. In fact, I would like to know if there is a way to collect performance metrics from "CAdvisor" container (not from cgroup) at runtime ? I mean, extract performance values from the curves designed by cadvisor like memory usage or network traffic. I need to record this values and save them in a database so that, I can perform a statistic analyzes upon these generated values (like comparing memory consumption for two docker containers at t=50s).

Thanks in advance.


Solution

  • cAdvisor does provide a rest endpoint to get any stats in real time. By default, it keeps latest two minute of data. You can configure it to keep more or less. It also supports a storage backend to keep dumping stats to an influxdb database.

    REST Api:

    eg. /api/v1.3/containers doc: https://github.com/google/cadvisor/blob/master/docs/api.md

    Doc on setting up InfluxDB: https://github.com/google/cadvisor/blob/master/docs/influxdb.md