Docker监控——Prometheus

发布时间:2024-12-01 点击:64
云计算
博文大纲:
一、docker的监控
二、prometheus简介
三、prometheus组成及架构
四、部署prometheus
1)环境准备
2)部署prometheus
3)配置peometheus监控实现报警
一、docker的监控
(1)docker自带的监控命令
[root@localhost ~]# docker top wordpress_wordprss_1 //查看容器的使用状态uid pid ppid c stime tty time cmdroot 5601 5569 0 20:53 ? 00:00:00 apache2 -dforeground33 6073 5601 0 20:54 ? 00:00:00 apache2 -dforeground33 6074 5601 0 20:54 ? 00:00:00 apache2 -dforeground33 6075 5601 0 20:54 ? 00:00:00 apache2 -dforeground33 6076 5601 0 20:54 ? 00:00:00 apache2 -dforeground33 6077 5601 0 20:54 ? 00:00:00 apache2 -dforeground33 6096 5601 0 20:54 ? 00:00:00 apache2 -dforeground33 6098 5601 0 20:54 ? 00:00:00 apache2 -dforeground33 6099 5601 0 20:54 ? 00:00:00 apache2 -dforeground33 6100 5601 0 20:54 ? 00:00:00 apache2 -dforeground33 6155 5601 0 20:57 ? 00:00:00 apache2 -dforeground[root@localhost ~]# docker stats wordpress_wordprss_1 [root@localhost ~]# docker logs wordpress_wordprss_1 //这三条都是容器本身自带的监控命令(2)sysdig
[root@localhost ~]# docker run -it --rm --name sysdig --privileged=true --volume=/var/run/docker.sock:/host/var/run/docker.sock --volume=/dev:/host/dev --volume=/proc:/host/proc:ro --volume=/boot:/host/boot:ro --volume=/lib/modules:/host/lib/modules:ro --volume=/usr:/host/usr:ro sysdig/sysdig//创建一个容器并自动进入容器中//--rm:随着退出容器而被删除;//--privileged=true:赋予特殊权限;root@711dbeb59fdd:/# csysdig //执行这条命令如图:
图中可以使用键盘和鼠标进行操作!
(3)scope
[root@localhost ~]# curl -l git.io/scope -o /usr/local/bin/scope[root@localhost ~]# chmod x /usr/local/bin/scope //下载安装脚本[root@localhost ~]# scope launch //以容器方式启动……………………weave scope is listening at the following url(s): * http://172.21.0.1:4040/ * http://192.168.122.1:4040/ * http://172.22.0.1:4040/ * http://172.20.0.1:4040/ * http://172.18.0.1:4040/ * http://172.19.0.1:4040/ * http://192.168.1.1:4040///根据末尾的提示信息进行访问如图:
根据图中的提示,自行可以点击进行测试!
如果要监控两台的话:主机名必须进行区分方法如下:
[root@dockera ~]# curl -l git.io/scope -o /usr/local/bin/scope[root@dockera ~]# chmod x /usr/local/bin/scope[root@dockera ~]# scope launch 192.168.1.1 192.168.1.2 //首选指定本地的ip,再指定对方的ip[root@dockera ~]# docker run -itd --name http httpd //运行一个容器进行测试[root@dockerb ~]# curl -l git.io/scope -o /usr/local/bin/scope[root@dockerb ~]# chmod x /usr/local/bin/scope[root@dockerb ~]# scope launch 192.168.1.2 192.168.1.1[root@dockerb ~]# docker run -itd --name nginx nginx访问(dockera、dockerb任意一台即可)测试:
二、prometheus简介
prometheus是一套开源的系统监控报警框架。它以给定的时间间隔从已配置的目标收集指标,评估规则表达式,显示结果,并在发现某些情况为真时触发警报。
作为新一代的监控框架,prometheus具有以下特点 :
强大的多维度数据模型:
(1)时间序列数据通过metric名和键值对来区分;
(2)所有的metrics都可以设置任意的多维标签;
(3)数据模型更随意,,不需要刻意设置为以点分隔的字符串;
(4)可以对数据模型进行聚合

免费企业邮箱哪个好
谈产品人的沟通
苹果第四财季营收629亿美元 净利同比增32%
电脑开机弹出nvstreamsvc.exe应用程序错误如何解决
为价值付费还是自己在交智商税
域名和商标发生冲突怎么办 如何解决商标和域名不一致
云服务器怎么保证不被攻击
安全删除硬件图标不见了怎么办