docker监控

采用prometheus和grafana监控
安装Noderexporter和Cadvisor

docker stop cadvisor
docker rm cadvisor
sudo docker run \
--volume=/:/rootfs:ro \
--volume=/var/run:/var/run:rw \
--volume=/sys:/sys:ro \
--volume=/var/lib/docker/:/var/lib/docker:ro \
--publish=8081:8080 \
--detach=true \
--name=cadvisor \
docker.io/google/cadvisor
docker stop nodeexporter
docker rm nodeexporter
docker run -d -p 9100:9100 \
  -v "/proc:/host/proc:ro" \
  -v "/sys:/host/sys:ro" \
  -v "/:/rootfs:ro" \
  --net="host" \
  quay.io/prometheus/node-exporter
docker stop prometheus
docker rm prometheus
docker run -itd -p 9090:9090 \
-v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \
-v /opt/prometheus/prometheus-data:/prometheus \
-v /etc/localtime:/etc/localtime:ro \
--privileged=true \
--restart always \
--name=prometheus \
docker.io/prom/prometheus

配置

# my global config
global:
  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    static_configs:
      - targets: ['192.168.1.54:9090']
  - job_name: 'mysql'
    scrape_interval: 5s
    static_configs:
      - targets: ['192.168.1.54:9104']
        labels:
          instance: cargts_ali
  - job_name: 'nodeexporter'
    scrape_interval: 5s
    static_configs:
      - targets: ['192.168.1.54:9100']
        labels:
          instance: node
  - job_name: 'docker-monitor'
    scrape_interval: 5s
    static_configs:
      - targets: ['192.168.1.54:8081']
        labels:
          group: 'prod'

kafka监控

https://www.robustperception.io/monitoring-kafka-with-prometheus/

解决问题

1.cadvisor无法映射路径的问题
sudo mount -o remount,rw '/sys/fs/cgroup'
sudo ln -s /sys/fs/cgroup/cpu,cpuacct /sys/fs/cgroup/cpuacct,cpu
2.导入模板无法显示的问题
添加数据源的时候要注意:将Prometheus的p大写!
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 如今,越来越多的公司开始使用 Docker 了,现在来给大家看几组数据: 2 / 3 的公司在尝试了 Docker...
    OneAPM阅读 5,453评论 0 15
  • 文档来源 文档来源:How to setup Docker Monitoring 由garyond翻译、校正及整理...
    garyond阅读 13,031评论 4 22
  • Cadvisor是Google用来监测单节点的资源信息的监控工具。它的资源消耗也比较低。但是,它有它的局限性,它只...
    Superwind20阅读 3,385评论 0 0
  • 小编在这里向大家推荐几款服务器监控和告警系统bosun,cAdvisor以及Prometheus. Bonus是一...
    行书以鉴阅读 13,759评论 1 20
  • 我的父亲,他叫孙美美。 对了他还有一个名字,叫老猴子。 小时候,父亲不在我身边,直到三四岁时候,他才从烟台调回来,...
    小深谷阅读 2,801评论 0 2

友情链接更多精彩内容