1、环境说明:
公司内部有k8s集群,利用k8s集群的prometheus来监控公司其他服务(linux主机搭建),
如果需要自行搭建prometheus,请参考:https://wqblogs.com/2020/04/09/prometheus%E9%83%A8%E7%BD%B2/
公司内部服务器系统都是Centos7.8
2、搭建:
(1)在所需监控的服务器上安装node_exporters
添加yaml源
curl -Lo /etc/yum.repos.d/_copr_ibotty-prometheus-exporters.repo https://copr.fedorainfracloud.org/coprs/ibotty/prometheus-exporters/repo/epel-7/ibotty-prometheus-exporters-epel-7.repo
安装
yum install node_exporter
启动,并设置开机启动
systemctl start node_exporter.service && systemctl enable node_exporter
(2)与prometheus集成
编辑pormetheus的cm文件,添加如下内容,如果有多台中间用逗号隔开:
重载prometheuscurl -XPOST http://192.168.0.102:30090/-/reload
(3)搭建grafana,并与prometheus集成
本次只是简单的测试,docker启动,并未做数据持久化docker run -d -p 3000:3000 grafana/grafana
容器启动后,即可通过http://Ip:3000进行对grafana的访问
默认用户名密码为:admin/admin
如下图所示
进行集成:
点击设置,选择Data Sources
填写相关信息,我这里只填写了访问prometheus的url,其他的可不填,如下图所示:
点击保存
按照下图进行操作,导入模板,
具体模板参考:https://grafana.com/grafana/dashboards?dataSource=prometheus&search=linux
选择适合自己的模板,
复制ID,
填写,点击Load,弹出如下对话框,点击Import
添加完成后点击grafana图标,则可以看到刚才添加的模板,点开可以查看详细信息,
至些环境完成搭建