监控系统promtheus搭建
1.promtheus监控服务端
https://prometheus.io/download/
2.prometheus客户端(如windows)
https://github.com/prometheus-community/windows_exporter/
二、启动服务,配置服务端。
1.客户端,下载windows_exporter后安装。安装后会有进程:
如果是linux,
linux客户端是叫node_exporter,此node并非前端在的nodeJs而是节点的意思。在promtheus官网可下载。
tar -xvf node_exporter-1.3.1.linux-amd64.tar.gz
cat > /etc/systemd/system/node_exporter.service << EOF [Unit] Description=node_exporter Documentation=https://prometheus.io/ After=network.target [Service] Type=simple User=root ExecStart=/root/node_exporter-1.3.1.linux-amd64/node_exporter Restart=on-failure [Install] WantedBy=multi-user.target EOF
systemctl start node_exporter这里直接用的root账号,网上很多文章都是新加了一个用户做这事。然后开一下防火墙9100端口,在grafana里导入8919模板即可。
2.服务端
./prometheus --config.file=prometheus.ymlwindows版是prometheus.exe
进入http://localhost:9090/metrics,可查看指标
配置prometheus.yml,添加:
- job_name: 'windows' static_configs: - targets: ['192.168.1.xx:9182']
配置后重启服务可以看到windows的监控情况:
http://localhost:9090/targets?search=
三、下载grafana
我这里用的windows版
https://grafana.com/docs/grafana/next/setup-grafana/installation/windows/
下载后执行grafana-server.exe,msi的安装可能是服务的形式。
windows的grafana的grafana-server进程杀不掉,结束了进程会再启一个。后面才发现安装包有个nssm.exe,他把grafana注册成了服务,所以有这个特征。要停止是停止grafana服务。
启动会用到3000端口,启动后有一个grafana-server进程。
四、配置grafana
1.设置Prometheus数据源
Configuration -> Data Sources ->add data source -> Prometheus
2.配置windows_exporter的视图
a.导入,输入10467的模板,选择上面加入的windows节点
这里的job名同prometheus.yml里的配置的job名。
最后,就可以看到监控信息了。
java的监控,即可以是java进程,也可以是tomcat:
https://github.com/prometheus/jmx_exporter/
同样,先在prometheus.yml添加,后在grafana里配置。
使用id为8563进行grafana配置。