部署Prometheus
  • 为什么会有本书
  • Part I - Prometheus基础
    • 第一章 简介
    • 第二章 部署
      • 二进制部署
      • Docker部署
      • Kubernetes部署
    • 第三章 集群与高可用
      • Prometheus
      • Alertmanager
  • Part II - Prometheus数据采集与告警
    • 第四章 数据采集
      • 主机
        • Linux
        • Windows
        • Docker
        • PushGateway
      • Web服务器
        • Nginx
        • Tomcat
      • 数据库
        • MySQL
        • Redis
      • 消息队列
        • RabbitMQ
        • Kafka
      • 微服务
        • Eureka
        • Nacos
        • Zookeeper
        • Consul
      • 网络探测
    • 第五章 告警规则
      • 主机
        • Linux
        • Windows
        • Docker
        • PushGateway
      • Web服务器
        • Nginx
        • Tomcat
      • 数据库
        • MySQL
        • Redis
      • 消息队列
        • RabbitMQ
        • Kafka
      • 微服务
        • Eureka
        • Nacos
        • Zookeeper
        • Consul
      • 网络探测
    • 第六章 告警处理
  • Part III -Prometheus数据展示
    • 第七章 数据展示
Powered by GitBook
On this page
  • 安装Docker
  • 启动cAdvisor
  • 添加Prometheus配置

Was this helpful?

  1. Part II - Prometheus数据采集与告警
  2. 第四章 数据采集
  3. 主机

Docker

cAdviosr是Google开源的用于Docker监控的镜像,启动时挂载本地几个特定目录,并暴露端口即可。

安装Docker

既然要监控Docker,那么Docker肯定已经安装好了。

启动cAdvisor

这里随机指定本地端口为48080

# 启动cadvisor容器
docker run \
  --volume=/:/rootfs:ro \
  --volume=/var/run:/var/run:rw \
  --volume=/sys:/sys:ro \
  --volume=/var/lib/docker/:/var/lib/docker:ro \
  --publish=48080:8080 \
  --detach=true \
  --name=cadvisor \
  --restart=always \
  google/cadvisor:latest

# 防火墙放行
firewall-cmd --add-port=48080/tcp --permanent
firewall-cmd --reload

然后访问ip:48080/metrics即可查看metrics数据。

添加Prometheus配置

加入需求监控的主机,然后重启Prometheus或者热加载配置。

# 修改加入内容
vi prometheus.yml

scrape_configs:
  - job_name: docker
    static_configs:
    - targets: 
      - ip:48080
      labels:
        instance: docker_name

# 重启Prometheus
# 如果你是systemd管理
systemctl restart prometheus
如果你是supervisor管理
supervisorctl restart prometheus
PreviousWindowsNextPushGateway

Last updated 5 years ago

Was this helpful?