前几天我在mesos平台上基于 cadvisor部署了 influxdb 和 grafana,用于监控 mesos 以及 docker app 运行信息,发现这套监控系统不太适合 mesos + docker 的架构,原因是:

1)mesos task id 和 docker container name 不一致

cadvisor 的设计基于 docker host,没有考虑到mesos 数据中心;

cadvisor 用 docker name(docker ps能看到)来标记抓取的数据,而 mesos 用 task id(在mesos ui 或者metrics里能看到) 来标记正在运行的任务。mesos task 的类型可以是 docker 容器,也可以是非容器。mesos task id 与docker container name 的命名也是完全不一样的。

上述问题导致 cadvisor 抓取到数据后,用户难以识别属于哪个 mesos task

2)cadvisor 和 grafana 不支持报警

经过查询资料,发现 mesos-exporter + prometheus + alert-manager 是个很好的组合,可以解决上述问题:

mesos-exporter 是 mesosphere 开发的工具,用于导出 mesos 集群包括 task 的监控数据并传递给prometheus;prometheus是个集 db、graph、statistic 于一体的监控工具;alert-manager 是 prometheus 的报警工具

搭建方法:

1. build mesos-exporter

git clone https://github.com/mesosphere/mesos_exporter.git
cd mesos_exporter
docker build -f Dockerfile -t mesosphere/mesos-exporter .

2. docker pull prometheus, alert-manager

3. 部署 mesos-exporter, alert-manager, prometheus

mesos-exporter:

{
"id": "mesos-exporter-slave",
"instances": 6,
"cpus": 0.2,
"mem": 128,
"args": [
"-slave=http://127.0.0.1:5051",
"-timeout=5s"
],
"constraints": [
["hostname","UNIQUE"],
["hostname", "LIKE", "slave[1-6]"]
],
"container": {
"type": "DOCKER",
"docker": {
"image": "172.31.17.36:5000/mesos-exporter:latest",
"network": "HOST"
},
"volumes": [
{
"containerPath": "/etc/localtime",
"hostPath": "/etc/localtime",
"mode": "RO"
}
]
}
}

请打开slave 防火墙的9110/tcp 端口

alert-manager:

{
"id": "alertmanager",
"instances": 1,
"cpus": 0.5,
"mem": 128,
"constraints": [
["hostname","UNIQUE"],
["hostname", "LIKE", "slave[1-6]"]
],
"labels": {
"HAPROXY_GROUP":"external",
"HAPROXY_0_VHOST":"alertmanager.test.com"
},
"container": {
"type": "DOCKER",
"docker": {
"image": "172.31.17.36:5000/alertmanager:latest",
"network": "BRIDGE",
"portMappings": [
{ "containerPort": 9093, "hostPort": 0, "servicePort": 0, "protocol": "tcp" }
]
},
"volumes": [
{
"containerPath": "/etc/localtime",
"hostPath": "/etc/localtime",
"mode": "RO"
},
{
"containerPath": "/etc/alertmanager/config.yml",
"hostPath": "/var/nfsshare/alertmanager/config.yml",
"mode": "RO"
},
{
"containerPath": "/alertmanager",
"hostPath": "/var/nfsshare/alertmanager/data",
"mode": "RW"
}
]
}
}

prometheus:

{
"id": "prometheus",
"instances": 1,
"cpus": 0.5,
"mem": 128,
"args": [
"-config.file=/etc/prometheus/prometheus.yml",
"-storage.local.path=/prometheus",
"-web.console.libraries=/etc/prometheus/console_libraries",
"-web.console.templates=/etc/prometheus/consoles",
"-alertmanager.url=http://alertmanager.test.com"
],
"constraints": [
["hostname","UNIQUE"],
["hostname", "LIKE", "slave[1-6]"]
],
"labels": {
"HAPROXY_GROUP":"external",
"HAPROXY_0_VHOST":"prometheus.test.com"
},
"container": {
"type": "DOCKER",
"docker": {
"image": "172.31.17.36:5000/prometheus:latest",
"network": "BRIDGE",
"portMappings": [
{ "containerPort": 9090, "hostPort": 0, "servicePort": 0, "protocol": "tcp" }
]
},
"volumes": [
{
"containerPath": "/etc/localtime",
"hostPath": "/etc/localtime",
"mode": "RO"
},
{
"containerPath": "/etc/prometheus",
"hostPath": "/var/nfsshare/prometheus/conf",
"mode": "RO"
},
{
"containerPath": "/prometheus",
"hostPath": "/var/nfsshare/prometheus/data",
"mode": "RW"
}
]
}
}

4. prometheus 配置

prometheus.yml

# my global config
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
evaluation_interval: 15s # By default, scrape targets every 15 seconds.
# scrape_timeout is set to the global default (10s). # Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'codelab-monitor' # Load and evaluate rules in this file every 'evaluation_interval' seconds.
rule_files:
# - "first.rules"
# - "second.rules" scrape_configs:
- job_name: 'mesos-slaves'
scrape_interval: 5s
metrics_path: '/metrics'
scheme: 'http'
target_groups:
- targets: ['172.31.17.31:9110', '172.31.17.32:9110', '172.31.17.33:9110', '172.31.17.34:9110', '172.31.17.35:9110', '172.31.17.36:9110']
- labels:
group: 'office'

  

待补充 ...

5. 报警设置

待补充 ...

6. 与 grafana 集成

prometheus的 graph 功能不太完善,可以与 grafana 集成,让 grafana 承担 graph 功能。

data source 设置:

7. 附:mesos metrics 和 statics 地址

http://master1:5050/metrics/snapshot

http://slave4:5051/metrics/snapshot

http://master1:5050/master/state.json

http://slave4:5051/monitor/statistics.json

用户可以基于上述页面的数据,编写自己的监控程序。

[系统集成] 部署 mesos-exporter 和 prometheus 监控 mesos task的更多相关文章

  1. 部署prometheus监控kubernetes集群并存储到ceph

    简介 Prometheus 最初是 SoundCloud 构建的开源系统监控和报警工具,是一个独立的开源项目,于2016年加入了 CNCF 基金会,作为继 Kubernetes 之后的第二个托管项目. ...

  2. Prometheus监控软件部署方法

    背景:负责基于区块链的某公正项目的状态上报模块设计编码,基于Prometheus进行二次开发 1.说明Prometheus 是一个开源的服务监控软件,它通过 HTTP 协议从远程机器收集数据并存储在本 ...

  3. Kubernetes集群部署史上最详细(二)Prometheus监控Kubernetes集群

    使用Prometheus监控Kubernetes集群 监控方面Grafana采用YUM安装通过服务形式运行,部署在Master上,而Prometheus则通过POD运行,Grafana通过使用Prom ...

  4. 使用 Docker 部署 Grafana + Prometheus 监控 MySQL 数据库

    一.背景 在平时开发过程当中需要针对 MySQL 数据库进行监控,这里我们可以使用 Grafana 和 Prometheus 来实现监控功能.Grafana 是一款功能强大的仪表盘面板,支持多种数据源 ...

  5. 基于k8s集群部署prometheus监控ingress nginx

    目录 基于k8s集群部署prometheus监控ingress nginx 1.背景和环境概述 2.修改prometheus配置 3.检查是否生效 4.配置grafana图形 基于k8s集群部署pro ...

  6. 基于k8s集群部署prometheus监控etcd

    目录 基于k8s集群部署prometheus监控etcd 1.背景和环境概述 2.修改prometheus配置 3.检查是否生效 4.配置grafana图形 基于k8s集群部署prometheus监控 ...

  7. 容器编排系统K8s之Prometheus监控系统+Grafana部署

    前文我们聊到了k8s的apiservice资源结合自定义apiserver扩展原生apiserver功能的相关话题,回顾请参考:https://www.cnblogs.com/qiuhom-1874/ ...

  8. 如何利用Prometheus监控你的应用

    Prometheus作为一套完整的开源监控接近方案,因为其诸多强大的特性以及生态的开放性,俨然已经成为了监控领域的事实标准并在全球范围内得到了广泛的部署应用.那么应该如何利用Prometheus对我们 ...

  9. 如何利用Prometheus监控你的应用(此列子是对于golang sdk进行运用)

    Prometheus作为一套完整的开源监控接近方案,因为其诸多强大的特性以及生态的开放性,俨然已经成为了监控领域的事实标准并在全球范围内得到了广泛的部署应用.那么应该如何利用Prometheus对我们 ...

随机推荐

  1. CentOS7 下 安装 supervisor以及使用

    CentOS7 下 安装 supervisor 以及使用 手动安装 [注] linux环境必须安装 python 1.获取supervisor包:[https://pypi.python.org/py ...

  2. Jquery仿彩票更换数字动画效果

    <script type="text/javascript" src="jquery-1.11.3.min.js"></script> ...

  3. _.属性和self.属性,我遇到的那些坑

    只怪当时_.属性和self.属性当时没有研究透,所以为自己掉入坑里埋下了伏笔.下面从我的坑开始说起: 我写了个懒加载,重写了一个数组属性的get方法,在get方法里面创建了一个数组来获取数据,那么调用 ...

  4. nginx 基本操作

    nginx 是什么 nginx 是轻量.高性能的网页服务器,相较 Apache 占有内存小. 下载 https://nginx.org/en/download.html 默认根目录 安装目录下的 ht ...

  5. tornado中self.write() 写list

    tornado源码中不支持在self.write()中直接传入list对象,源代码如下 def write(self, chunk): if self._finished: raise Runtime ...

  6. 使用VC6开发opengl配置

    2015-11-09 22:25 VC6中工程创建: ​(1)创建一个Win32 Console Application.(以我创建的为例,工程名为simpleGL)   (2)链接OpenGL li ...

  7. GitHub的用法:到GitHub上部署项目

    先提供两个较好的Git教程: 1. 如何在github部署项目: lhttp://jingyan.baidu.com/article/656db918fbf70ce381249c15.html 2. ...

  8. IOS懒加载

    1.懒加载基本 懒加载——也称为延迟加载,即在需要的时候才加载(效率低,占用内存小).所谓懒加载,写的是其get方法. 注意:如果是懒加载的话则一定要注意先判断是否已经有了,如果没有那么再去进行实例化 ...

  9. js中排序问题总结

    js的排序中通常使用到sort函数,可以用冒泡排序,插入排序,快速排序,希尔排序,系统方法等方法,本文结束后分享一个用着排序算法的链接,感兴趣可以了解了解. 1.常见的对一般数组进行排序,代码如下: ...

  10. Hot code replace failed

    今天在eclipses中 修改代码,保存时会出时不时出现Hot code replace failed 对话框,谷歌提示是在debug模式下保存修改源代码会出现此类问题.确实,刚刚在用debug功能, ...