prometheus-监控docker服务器
1. prometheus-监控docker服务器
prometheus-监控docker服务器
cAdvisor(Container Advisor):用于收集正在运行的容器资源使用和性能信息。
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服务器的更多相关文章
- Prometheus 监控Docker服务器及Granfanna可视化
Prometheus 监控Docker服务器及Granfanna可视化 cAdvisor(Container Advisor)用于收集正在运行的容器资源使用和性能信息. 使用Prometheus监控c ...
- Prometheus 监控linux服务器
Prometheus 监控linux服务器 node_exporter:用于*NIX系统监控,使用Go语言编写的收集器. 使用版本 node_exporter 0.17.0 相关文档 使用文档:htt ...
- Prometheus 监控Mysql服务器及Grafana可视化
Prometheus 监控Mysql服务器及Grafana可视化. mysql_exporter:用于收集MySQL性能信息. 使用版本 mysqld_exporter 0.11.0 官方地址 使用文 ...
- Prometheus监控Docker Swarm集群(一)
Prometheus监控Docker Swarm集群(一) cAdvisor简介 为了解决容器的监控问题,Google开发了一款容器监控工具cAdvisor(Container Advisor),它为 ...
- Grafana连接Prometheus监控Docker平台
Grafana是一款开源的分析平台. Grafana allows you to query, visualize, alert on and understand your metrics no m ...
- Prometheus入门到放弃(4)之cadvisor监控docker容器
Prometheus监控docker容器运行状态,我们用到cadvisor服务,cadvisor我们这里也采用docker方式直接运行. 1.下载镜像 [root@prometheus-server ...
- prometheus监控(小试牛刀)
prometheus监控(小试牛刀) 环境:全部服务都是基于docker运行 本文略微草率,好文章在这里,特别好如下: https://www.cnblogs.com/tchua/p/11120228 ...
- 6. 使用cadvisor监控docker容器
Prometheus监控docker容器运行状态,我们用到cadvisor服务,cadvisor我们这里也采用docker方式直接运行.这里我们可以服务端和客户端都使用cadvisor 客户端 1.下 ...
- cAdvisor+Prometheus+Grafana监控docker
cAdvisor+Prometheus+Grafana监控docker 一.cAdvisor(需要监控的主机都要安装) 官方地址:https://github.com/google/cadvisor ...
- 使用docker方式构建prometheus监控的学习
一.背景:近期学习部署prometheus监控系统,经研究发现prometheus提供docker运行模式.根据我的经验,能够使用docker模式构建系统一定多快好省. 二.环境: 1.centos7 ...
随机推荐
- 【Spring boot】启动过程源码分析
启动过程结论 推测web应用类型. spi的方式获取BootstrapRegistryInitializer.ApplicationContextInitializer.ApplicationCont ...
- 关于Redhat-7.x-下docker的安装记录
今天因公司项目,需要部署docker环境,能根据指定的镜像创建容器 于是首先就得先部署docker环境,过程记录如下: 在Redhat 7.x - (aws上的Redhat) 环境下部署过程 1.安装 ...
- day08-MySQL事务
MySQL事务 先来看一个例子 有一张balance表: 需求:将tom的100块钱转到King账户中 执行的操作是: update balance set money = money -100 wh ...
- Java程序员必会Synchronized底层原理剖析
synchronized作为Java程序员最常用同步工具,很多人却对它的用法和实现原理一知半解,以至于还有不少人认为synchronized是重量级锁,性能较差,尽量少用. 但不可否认的是synchr ...
- 任务清单小功能的实现(任务的增、删、改、查、存储)使用Vue实现
文章目录 1.实现的效果(视频演示) 2.重点讲解(编辑的实现) 2.1 提示(官网介绍nextTick的用法) 3.编辑功能的核心代码 4.完整的代码 5.以往练习 任务清单案例(纯Vue) 实现的 ...
- 什么是齐博/齐博CMS之X1?
齐博x1:核心+模块+插件+钩子的理念把系统的灵活性及拓展性做到了极致!!!齐博X1是齐博软件基于thinkphp5开发的内容管理系统,拓展性非常强,后台一键升级,后台提供丰富的频道模块云市插件市场. ...
- 微服务 Zipkin 链路追踪原理(图文详解)
一个看起来很简单的应用,可能需要数十或数百个服务来支撑,一个请求就要多次服务调用. 当请求变慢.或者不能使用时,我们是不知道是哪个后台服务引起的. 这时,我们使用 Zipkin 就能解决这个问题. 由 ...
- SqlDataAdapter使用小结
SqlDataAdapter是 DataSet与SQL Server之间的桥接器,用于相互之间的数据操作. 使用方法 1. 通过查询语句 与 SqlConnection对象实现 string strC ...
- 修改Oracle共享池大小
1. sysdba登录数据库 [oracle@ufdb165 ~]$ sqlplus /nolog SQL*Plus: Release 11.2.0.4.0 Production on Wed Au ...
- CC3
cc_link_three 0x00前言 这里要单独学cc链子三是因为它的调用方式不是执行命令而是代码执行,是一种动态类加载机制来执行代码,然后类加载的时候要用类加载器 0x01开整 首先明白调用机制 ...