Prometheus - how to control other docker containers

I want to use Prometheus to monitor docker containers . I can run Prometheus using Grafana , but I don’t know how to instruct him to control other docker containers. If possible, I would like to see an example. For example, my host has a Ubuntu container , as well as a Gentoo container . How can I say that Prometheus controlled them or maybe tracked some applications running inside? Thanks in advance for your time and patience.

+6
source share
1 answer

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:

cAdvisor with prometheus

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.

prometheus with grafana

+6

Source: https://habr.com/ru/post/1017284/


All Articles