Promethus+Grafana 监控linux、windows节点以及Tomcat项目
文件下载地址
Promethus https://github.com/prometheus/prometheus/releases/download/v2.9.1/prometheus-2.9.1.linux-amd64.tar.gz
Grafana https://dl.grafana.com/oss/release/grafana-5.4.2-1.x86_64.rpm
Linux节点 https://github.com/prometheus/node_exporter/releases/download/v0.17.0/node_exporter-0.17.0.linux-amd64.tar.gz
windows 节点 https://github.com/martinlindhe/wmi_exporter/releases/download/v0.7.0/wmi_exporter-0.7.0-386.exe
jmx_prometheus https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.3.1/jmx_prometheus_javaagent-0.3.1.jar
安装Promethus
选择目录下载文件
wget https://github.com/prometheus/prometheus/releases/download/v2.9.1/prometheus-2.9.1.linux-amd64.tar.gz
wget https://dl.grafana.com/oss/release/grafana-5.4.2-1.x86_64.rpm
解压promethus
tar -zxvf prometheus-2.9.1.linux-amd64.tar.gz
cd prometheus-2.9.1.linux-amd64
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
启动Promethus(加上&,表示后台启动)
./promethus &
访问http://IP:9090,可打开Promethus自带的监控页面;
安装Grafana
wget https://dl.grafana.com/oss/release/grafana-5.4.2-1.x86_64.rpm
rpm -ivh --nodeps grafana-5.4.2-1.x86_64.rpm
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable grafana-server.service
sudo /bin/systemctl start grafana-server.service
访问http://IP:3000,可打开Grafana图形页面;
默认用户名密码都是admin,初次登录会要求修改默认的登录密码,登陆后添加数据源“Add data source”,选择Promethus
Dashboards页面选择“Prometheus 2.0 Stats” ,Settings页面填写普罗米修斯地址并保存
切换到我们刚才添加的“Prometheus 2.0 Stats”即可看到整个监控页面
监控linux机器(node-exporter)
- Linux 节点
安装node-exporter
wget https://github.com/prometheus/node_exporter/releases/download/v0.17.0/node_exporter-0.17.0.linux-amd64.tar.gz
tar –zxvf node_exporter-0.17.0.linux-amd64.tar.gz
cd node_exporter-0.17.0.linux-amd64
./node_exporter &(默认端口为9100)
启动后浏览器访问http://IP:9100,查看信息,如出现以下信息,则客户端配置正确
- 服务端
cd prometheus-2.9.1.linux-amd64
vim prometheus.yml
添加如下信息
- job_name: 'linux'
static_configs:
- targets: ['IP(域名):9100']
labels:
instance: Prometheus
grafana导入画好的dashboard
链接:https://pan.baidu.com/s/1BT2TF85Wq79WAQ6O2eQvyA 提取码:v4s9
如果没有任何显示,是grafana缺少相关显示需要用到的插件piechart,grafana的默认插件目录是/var/lib/grafana/plugins,可以将下载好的插件解压到这个目录,重启grafana即可
piechart插件: 链接:https://pan.baidu.com/s/1XctVmKroMt484tRDtgVdRA 提取码:bv5d
service grafana-server restart
/usr/sbin/grafana-cli plugins ls #查看已安装插件
再刷新grafana页面,即可看到我们刚才设置好的node监控
监控windows机器(wmi-exporter)
被监控windows机器安装wmi-exporter,下载节点监控程序并运行,默认端口9182
下载地址: https://github.com/martinlindhe/wmi_exporter/releases/download/v0.7.0/wmi_exporter-0.7.0-386.exe
浏览器访问:http://IP:9182,出现如下信息则,客户端节点正常
- 服务端
cd prometheus-2.9.1.linux-amd64
vim prometheus.yml
添加如下信息
- job_name: 'windows'
static_configs:
- targets: ['IP(域名):9182]
labels:
instance: windows
重启Promethus
grafana导入画好的dashboard,选择普罗米修斯数据源
链接:https://pan.baidu.com/s/1iSZar_UoZm1L2qIUEV5FTw 提取码:i1pn
同样的方法导入画好的json文件
监控tomcat项目(jmx_exporter )
下载jmx_exporter、以及配置文件
jmx_exporter下载链接:https://pan.baidu.com/s/1nVSTyi6IRZqG5d1lbqWWYg 提取码:skw3
配置文件 下载链接:https://pan.baidu.com/s/1JPFVFivO_gG8BEGHAszweg 提取码:ryxt
将jar包以及配置文件放到/apache-tomcat-7.0.92/bin/下
tomcat目录修改/apache-tomcat-7.0.92/bin/catalina.sh,添加如下语句
JAVA_OPTS=" -javaagent:/opt/apache-tomcat-7.0.92/bin/jmx_prometheus_javaagent-0.3.1.jar=9151:/opt/apache-tomcat-7.0.92/bin/config.yaml"
切记,配置完成后shutdown命令不能使用,需要kill -9 PID 杀掉进程
- 服务端
cd prometheus-2.9.1.linux-amd64
vim prometheus.yml
添加如下信息
- job_name: 'tomcat'
static_configs:
- targets: ['IP(域名):9151]
labels:
instance: tomcat
重启Promethus
grafana导入画好的dashboard,选择普罗米修斯数据源
链接:https://pan.baidu.com/s/14h0Rp9XANdzUhPvhoyVrgQ 提取码:xf20
同样的方法导入画好的json文件