You can use cadvisor , which gives container users an idea of resource utilization and performance characteristics of their running containers.
A very good article on setting up Prometheus to monitor Docker uses this architecture:
In short, the idea is to collect container information using cAdvisor and put them in the Prometheus database . Grafana will query the Prometheus database and display control charts / values.
cAdvisor Prometheus, a > (prometheus.yml
):
scrape_configs:
- job_name: 'cadvisor'
scrape_interval: 5s
static_configs:
- targets: ['cadvisor:8080']
Prometheus, Grafana, . A () json
, Grafana, :
% :
"targets": [
{
"expr": "sum(rate(container_cpu_user_seconds_total{image!=\"\"}[1m])) / count(node_cpu{mode=\"system\"}) * 100",
"interval": "10s",
"intervalFactor": 1,
"legendFormat": "",
"refId": "A",
"step": 10
}
]
% :
"targets": [
{
"expr": "(sum(node_memory_MemTotal) - sum(node_memory_MemFree+node_memory_Buffers+node_memory_Cached) ) / sum(node_memory_MemTotal) * 100",
"interval": "10s",
"intervalFactor": 2,
"legendFormat": "",
"refId": "A",
"step": 20
}
]
json- ( ) :
git clone https://github.com/stefanprodan/dockprom
Grafana json.
docker swarm mode
, , github.