1. prometheus-监控docker服务器

  • prometheus-监控docker服务器

    • cAdvisor(Container Advisor):用于收集正在运行的容器资源使用和性能信息。

    • 项目地址:https://github.com/google/cadvisor

    • docker部署cAdvisor示例:

      docker run -d \
      --volume=/:/rootfs:ro \
      --volume=/var/run:/var/run:ro \
      --volume=/sys:/sys:ro \
      --volume=/var/lib/docker/:/var/lib/docker:ro \
      --volume=/dev/disk/:/dev/disk:ro \
      --publish=8080:8080 \
      --detach=true \
      --name=cadvisor \
      google/cadvisor:latest
  • 案例: 监控docker服务器

    • 监控执行命令

      docker run -d \
      --volume=/:/rootfs:ro \
      --volume=/var/run:/var/run:ro \
      --volume=/sys:/sys:ro \
      --volume=/var/lib/docker/:/var/lib/docker:ro \
      --volume=/dev/disk/:/dev/disk:ro \
      --publish=8080:8080 \
      --detach=true \
      --name=cadvisor \
      google/cadvisor:latest
    • 执行创建监控docker服务

      [root@VM-0-17-centos ~]# docker run -d \
      > --volume=/:/rootfs:ro \
      > --volume=/var/run:/var/run:ro \
      > --volume=/sys:/sys:ro \
      > --volume=/var/lib/docker/:/var/lib/docker:ro \
      > --volume=/dev/disk/:/dev/disk:ro \
      > --publish=8080:8080 \
      > --detach=true \
      > --name=cadvisor \
      > google/cadvisor:latest
      Unable to find image 'google/cadvisor:latest' locally
      latest: Pulling from google/cadvisor
      ff3a5c916c92: Pull complete
      44a45bb65cdf: Pull complete
      0bbe1a2fe2a6: Pull complete
      Digest: sha256:815386ebbe9a3490f38785ab11bda34ec8dacf4634af77b8912832d4f85dca04
      Status: Downloaded newer image for google/cadvisor:latest
      78d6d7db3b715f5800346cd592575a4b7be5e644e198dbf95160e64c3545fa53
    • 进行数据访问http://ip:8080

    • 配置prometheus添加服务

      [root@prometheus ~]# cd /opt/monitor/
      [root@prometheus monitor]# ll
      total 23072
      drwxr-xr-x 2 3434 3434 93 Jun 7 14:39 alertmanager
      -rw-r--r-- 1 root root 23624308 May 11 04:11 alertmanager-0.22.0-rc.1.linux-amd64.tar.gz
      drwxr-xr-x 8 root root 157 Jun 6 17:18 grafana
      drwxr-xr-x 5 3434 3434 145 Jun 7 17:07 prometheus
      [root@prometheus monitor]# cd prometheus/
      [root@prometheus prometheus]# ll
      total 167980
      drwxr-xr-x 2 3434 3434 38 Mar 17 04:20 console_libraries
      drwxr-xr-x 2 3434 3434 173 Mar 17 04:20 consoles
      -rw-r--r-- 1 3434 3434 11357 Mar 17 04:20 LICENSE
      -rw-r--r-- 1 3434 3434 3420 Mar 17 04:20 NOTICE
      -rwxr-xr-x 1 3434 3434 91044140 Mar 17 02:10 prometheus
      -rw-r--r-- 1 3434 3434 1043 Jun 7 17:07 prometheus.yml
      -rwxr-xr-x 1 3434 3434 80944687 Mar 17 02:12 promtool
      drwxr-xr-x 2 root root 22 Jun 7 14:43 rules
      [root@prometheus prometheus]# vim prometheus.yml
      [root@prometheus prometheus]# cat prometheus.yml
      # 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:
      - 127.0.0.1:9093 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
      rule_files:
      - "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: ['127.0.0.1:9090']
      - job_name: 'linux server'
      static_configs:
      - targets: ['121.4.78.187:9100']
      labels:
      prod: 'web1'
      - job_name: 'docker server'
      static_configs:
      - targets: ['121.4.63.211:8080']
      labels:
      prod: 'web2'
    • 重新加载prometheus服务

      [root@prometheus prometheus]# /bin/systemctl restart prometheus
      [root@prometheus prometheus]# /bin/systemctl status prometheus
      ● prometheus.service - prometheus
      Loaded: loaded (/usr/lib/systemd/system/prometheus.service; enabled; vendor preset: disabled)
      Active: active (running) since Mon 2021-06-07 22:53:36 CST; 4s ago
      Main PID: 14647 (prometheus)
      CGroup: /system.slice/prometheus.service
      └─14647 /opt/monitor/prometheus/prometheus --config.file=/opt/monitor/prometheus/prometheus.yml Jun 07 22:53:36 prometheus prometheus[14647]: level=info ts=2021-06-07T14:53:36.914Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=1...egment=19
      Jun 07 22:53:36 prometheus prometheus[14647]: level=info ts=2021-06-07T14:53:36.958Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=1...egment=19
      Jun 07 22:53:36 prometheus prometheus[14647]: level=info ts=2021-06-07T14:53:36.990Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=1...egment=19
      Jun 07 22:53:36 prometheus prometheus[14647]: level=info ts=2021-06-07T14:53:36.990Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=1...egment=19
      Jun 07 22:53:36 prometheus prometheus[14647]: level=info ts=2021-06-07T14:53:36.990Z caller=head.go:745 component=tsdb msg="WAL replay completed" checkpo....353439ms
      Jun 07 22:53:36 prometheus prometheus[14647]: level=info ts=2021-06-07T14:53:36.993Z caller=main.go:799 fs_type=XFS_SUPER_MAGIC
      Jun 07 22:53:36 prometheus prometheus[14647]: level=info ts=2021-06-07T14:53:36.993Z caller=main.go:802 msg="TSDB started"
      Jun 07 22:53:36 prometheus prometheus[14647]: level=info ts=2021-06-07T14:53:36.993Z caller=main.go:928 msg="Loading configuration file" filename=/opt/mo...theus.yml
      Jun 07 22:53:36 prometheus prometheus[14647]: level=info ts=2021-06-07T14:53:36.996Z caller=main.go:959 msg="Completed loading of configuration file" filename=/op…µs
      Jun 07 22:53:36 prometheus prometheus[14647]: level=info ts=2021-06-07T14:53:36.996Z caller=main.go:751 msg="Server is ready to receive web requests."
      Hint: Some lines were ellipsized, use -l to show in full.
    • 浏览器验证prometheus配置文件是否生成

    • 使用grafana进行监控docker服务数据展示

      • 导入监控docker的仪表盘,ID为193

      • 填写名称,选择数据源

      • 发现已有监控数据了

    • 监控docker服务添加一个导航栏









      点击save dashboard保存

      发现有了导航点击数据没有变化

      我们需要修改图表信息

      每张图片添加如上信息



      发现修改之后,就有了变化了

prometheus-监控docker服务器的更多相关文章

  1. Prometheus 监控Docker服务器及Granfanna可视化

    Prometheus 监控Docker服务器及Granfanna可视化 cAdvisor(Container Advisor)用于收集正在运行的容器资源使用和性能信息. 使用Prometheus监控c ...

  2. Prometheus 监控linux服务器

    Prometheus 监控linux服务器 node_exporter:用于*NIX系统监控,使用Go语言编写的收集器. 使用版本 node_exporter 0.17.0 相关文档 使用文档:htt ...

  3. Prometheus 监控Mysql服务器及Grafana可视化

    Prometheus 监控Mysql服务器及Grafana可视化. mysql_exporter:用于收集MySQL性能信息. 使用版本 mysqld_exporter 0.11.0 官方地址 使用文 ...

  4. Prometheus监控Docker Swarm集群(一)

    Prometheus监控Docker Swarm集群(一) cAdvisor简介 为了解决容器的监控问题,Google开发了一款容器监控工具cAdvisor(Container Advisor),它为 ...

  5. Grafana连接Prometheus监控Docker平台

    Grafana是一款开源的分析平台. Grafana allows you to query, visualize, alert on and understand your metrics no m ...

  6. Prometheus入门到放弃(4)之cadvisor监控docker容器

    Prometheus监控docker容器运行状态,我们用到cadvisor服务,cadvisor我们这里也采用docker方式直接运行. 1.下载镜像 [root@prometheus-server ...

  7. prometheus监控(小试牛刀)

    prometheus监控(小试牛刀) 环境:全部服务都是基于docker运行 本文略微草率,好文章在这里,特别好如下: https://www.cnblogs.com/tchua/p/11120228 ...

  8. 6. 使用cadvisor监控docker容器

    Prometheus监控docker容器运行状态,我们用到cadvisor服务,cadvisor我们这里也采用docker方式直接运行.这里我们可以服务端和客户端都使用cadvisor 客户端 1.下 ...

  9. cAdvisor+Prometheus+Grafana监控docker

    cAdvisor+Prometheus+Grafana监控docker 一.cAdvisor(需要监控的主机都要安装) 官方地址:https://github.com/google/cadvisor ...

  10. 使用docker方式构建prometheus监控的学习

    一.背景:近期学习部署prometheus监控系统,经研究发现prometheus提供docker运行模式.根据我的经验,能够使用docker模式构建系统一定多快好省. 二.环境: 1.centos7 ...

随机推荐

  1. liunx的三个时间atime,mtime,ctime详细说明与使用场景

    导航:一.文件与文件夹三个时间:atime,mtime,ctime的含义二.ll命令查看文件时间三.stat命令查看文件的时间四.测试创建/修改文件的时间五.常用命令关于文件时间相关 - - - - ...

  2. POJ3398 Perfect Service (树形DP)

    对于每个u要设置三维. dp[u][0]表示u是服务器,以u为根的最小服务器数,其子节点既可以是,也可以不是,dp[u][0]+=min(d[v][0],d[v][1]); dp[u][1]表示u不是 ...

  3. 关于javascript:void(0) 在不用的浏览器当中的表现

    原因在于三款浏览器,对三个属性的处理顺序不同. Chrome顺序:onclick -> href -> target IE和Firefox顺序:onclick -> target - ...

  4. day01-4-订座功能

    满汉楼01-4 4.功能实现03 4.5订座功能 4.5.1功能说明 如果该餐桌处于已经预定或者就餐状态时,不能进行预定,并给出相应提示 4.5.2思路分析 根据显示界面,要考虑以下两种状态 检测餐桌 ...

  5. Redis 01: 非关系型数据库 + 配置Redis

    数据库应用的发展历程 单机数据库时代:一个应用,一个数据库实例 缓存时代:对某些表中的数据访问频繁,则对这些数据设置缓存(此时数据库中总的数据量不是很大) 水平切分时代:将数据库中的表存放到不同数据库 ...

  6. LVS之NAT、DR、TUNNEL实验

    1.LVS-NAT规则+WRR算法 服务器 IP地址 作用 系统版本 RS1 10.0.0.8/24GW:10.0.0.101 网站服务器 Rocky8.6 RS2 10.0.0.18/24GW:10 ...

  7. 解决pip下载速度慢问题

    解决pip下载速度慢的问题 痛点:当我们pip 安装第三方库的时候,由于是访问的国外地址,所以会出现下载很慢!干等..... 解决方案: # 1.在C盘目录-->Users-->用户--& ...

  8. Oracle pfile与spfile文件参数(转载)

    一.pfile与spfile Oracle中的参数文件是一个包含一系列参数以及参数对应值的操作系统文件.它们是在数据库实例启动时候加载的,决定了数据库的物理 结构.内存.数据库的限制及系统大量的默认值 ...

  9. K8S之prometheus-operator监控

    prometheus-operator 1. Prometheus Operator介绍 介绍文章:http://t.zoukankan.com/twobrother-p-11164391.html ...

  10. Spring学习笔记 - 第一章 - IoC(控制反转)、IoC容器、Bean的实例化与生命周期、DI(依赖注入)

    Spring 学习笔记全系列传送门: 目录 1.学习概述 2.Spring相关概念 2.1 Spring概述 2.1.1 Spring能做的工作 2.1.2 重点学习的内容 2.1.3 Spring发 ...