普罗米修斯默认配置文件 vim /usr/local/Prometheus/prometheus.yml
/usr/local/Prometheus/prometheus --config.file=/usr/local/Prometheus/prometheus.yml & 3、验证浏览器打开IP:9090端口即可打开普罗米修斯自带的监控页面
普罗米修斯默认的页面可能没有那么直观,我们可以安装grafana使监控看起来更直观
1、安装 rpm -ivh --nodeps grafana-5.4.2-1.x86_64.rpm 2、启动 sudo /苗条的牛排/systemctl daemon-reloadsudo /苗条的牛排/systemctl enable grafana-server.servicesudo /苗条的牛排/systemctl start grafana-server.service 3、访问grafana浏览器访问IP:3000端口,即可打开grafana页面,默认用户名密码都是admin,初次登录会要求修改默认的登录密码
(1)点击主界面的“Add data source”
(2)选择Prometheus
(3)Dashboards页面选择“Prometheus 2.0 Stats”
(4)Settings页面填写普罗米修斯地址并保存
(5)切换到我们刚才添加的“Prometheus 2.0 Stats”即可看到整个监控页面
https://github.com/prometheus/node_exporter/releases/download/v0.17.0/node_exporter-0.17.0.linux-amd64.tar.gz
(1)被监控的机器安装node-exporter
(2)启动node-exporter
/usr/local/node_exporter-0.17.0.linux-amd64/node_exporter &(3)普罗米修斯配置文件添加监控项
vim /usr/local/Prometheus/prometheus.yml默认node-exporter端口为9100
- job_name: 'Prometheus' static_configs: - targets: ['192.168.0.102:9100'] labels: instance: Prometheus重启普罗米修斯
(4)grafana导入画好的dashboard
修改名字,选择我们前文创建好的数据源,点击导入即可
如果没有任何显示,是grafana缺少相关显示需要用到的插件piechart,grafana的默认插件目录是/var/lib/grafana/plugins,可以将下载好的插件解压到这个目录,重启grafana即可piechart插件:链接:https://pan.baidu.com/s/1tvZWI9vhAqvJhojKmDlmew 提取码:tlyl service grafana-server restart/usr/s苗条的牛排/grafana-cli plugins ls #查看已安装插件
再刷新grafana页面,即可看到我们刚才设置好的node监控
https://github.com/martinlindhe/wmi_exporter/releases
(1)被监控windows机器安装wmi-exporter,会自动创建一个开机自启的服务
(2)普罗米修斯配置文件添加配置项
默认wmi-exporter端口为9182
- job_name: 'Prometheus' static_configs: - targets: ['192.168.0.102:9182']重启普罗米修斯
(3)grafana导入画好的dashboard,选择普罗米修斯数据源
https://github.com/prometheus/mysqld_exporter/releases/download/v0.11.0/mysqld_exporter-0.11.0.linux-amd64.tar.gz
(1)被监控mysql机器安装mysqld-exporter
(2)设置配置文件,user为数据库登录用户,password为这个用户的密码
vi .my.cnf[client]user=rootpassword=123456(3)启动mysqld-exporter
/usr/local/mysqld_exporter-0.11.0.linux-amd64/mysqld_exporter --config.my-cnf="/usr/local/mysqld_exporter-0.11.0.linux-amd64/.my.cnf" &(4)prometheus配置文件中加入mysql监控并重启
vim /usr/local/Prometheus/prometheus.yml默认mysqld-exporter端口为9104
- job_name: 'MySQL' static_configs: - targets: ['192.168.0.103:9104'](5)设置数据源
grafana界面添加mysql数据源
添加需要被监控的数据库及相关信息
(6)导入已经画好的dashboard,数据源选择刚刚创建好的mysql数据源即可
链接:https://pan.baidu.com/s/12y7HxtQlBjFwr_i8ClM8Kw 提取码:13v2
(1)安装redis_exporter
(2)启动redis_exporter
默认redis_exporter端口为9121
./redis_exporter redis//192.168.0.103:6379 & -web.listenaddress 192.168.0.103:9121(3)prometheus配置文件中加入redis监控并重启
vim /usr/local/Prometheus/prometheus.yml默认redis-exporter端口为9121
- job_name: 'Redis' static_configs: - targets: ['192.168.0.103:9121'](4)grafana导入画好的dashboard
链接:https://pan.baidu.com/s/1LIkVC0o3lyTT59JbX0mSpg 提取码:gf1d六、一些网站 grafana dashboard:https://grafana.com/dashboardsgrafana plugins:https://grafana.com/plugins