Cadvisor产品简介
Cadvisor是Google开源的一款用于展示和分析容器运行状态的可视化工具。通过在主机上运行Cadvisor用户可以轻松的获取到当前主机上容器的运行统计信息,并以图表的形式向用户展示。
接着上一篇来继续
部署Ca dvisor
被监控主机上部署Cadvisor容器
清空原来的
[root@agent ~]# docker rm -f $(docker ps -aq)
c78b7f80fd41
a76c56a3155b
14c0398f35a2
a0010d5c535f
root@agent \~\]# 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 fbd537636358169b4bcbce652b94211b06c4c7aee41362ceeb456004510b7e82
访问cAdvisor页面
访问http://192.168.50.50:8080 cAdvisor页面可以看到收集到的数据


Prometheus 产品 简介
Prometheus是一个最初在SoundCloud上构建的开源系统监视和警报工具包。自2012年成立以来,很多公司和组织都采用了Prometheus,该项目拥有非常活跃的开发者和用户社区。 它现在是一个独立的开源项目,可以独立于任何公司进行维护。 为了强调这一点,并阐明项目的治理结构,Prometheus于2016年加入Cloud Native Computing Foundation(云原生基金会),作为继Kubernetes之后的第二个托管项目。
Prometheus的主要特征有:
- 多维度数据模型-由指标键值对标识的时间序列数据组成
- PromQL,一种灵活的查询语言
- 不依赖分布式存储; 单个服务器节点是自治的
- 以HTTP方式,通过pull模型拉取时间序列数据
- 支持通过中间网关推送时间序列数据
- 通过服务发现或者静态配置,来发现目标服务对象
- 支持多种多样的图表和界面展示
部署 Prometheus
root@agent \~\]# docker pull prom/prometheus
> Using default tag: latest
>
> \*latest: Pulling from prom/prometheus
>
> 3cb635b06aa2: Pull complete
>
> 34f699df6fe0: Pull complete
>
> 33d6c9635e0f: Pull complete
>
> f2af7323bed8: Pull complete
>
> c16675a6a294: Pull complete
>
> 827843f6afe6: Pull complete
>
> 3d272942eeaf: Pull complete
>
> 7e785cfa34da: Pull complete
>
> 05e324559e3b: Pull complete
>
> 170620261a59: Pull complete
>
> ec35f5996032: Pull complete
>
> 5509173eb708: Pull complete
>
> Digest: sha256:cb9817249c346d6cfadebe383ed3b3cd4c540f623db40c4ca00da2ada45259bb
>
> Status: Downloaded newer image for prom/prometheus:latest
>
> docker.io/prom/prometheus:latest
### 配置prometheus.yml
**一定注意格式很容易出错**
[root@agent ~]# vim /tmp/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:
# - 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=