监控神器普罗米修斯Prometheus安装配置「建议收藏」

监控神器普罗米修斯Prometheus安装配置「建议收藏」一、基础环境环境/组件版本下载地址操作系统CentOS7.3http://archive.kernel.org/centos-vault/7.3.1611/isos/x86_64/CentOS-7-x86_64-DVD-1611.isoPrometheus2.6.0https://prometheus.io/download/#prometheusgo…

大家好,又见面了,我是你们的朋友全栈君。

一、基础环境

环境/组件 版本 下载地址
操作系统 CentOS 7.3 http://archive.kernel.org/centos-vault/7.3.1611/isos/x86_64/CentOS-7-x86_64-DVD-1611.iso
Prometheus 2.6.0 https://prometheus.io/download/#prometheus
go 1.11.4 https://golang.org/dl/
Grafana 5.4.2 https://dl.grafana.com/oss/release/grafana-5.4.2-1.x86_64.rpm

二、安装go

1、解压安装
tar -C /usr/local/ -xvf go1.11.4.linux-amd64.tar.gz
2、配置环境变量
vim /etc/profile

export PATH=$PATH:/usr/local/go/bin

source /etc/profile
3、验证
go version

在这里插入图片描述

三、安装Prometheus

1、安装
tar -C /usr/local/ -xvf prometheus-2.6.0.linux-amd64.tar.gz
ln -sv /usr/local/prometheus-2.6.0.linux-amd64/ /usr/local/Prometheus
2、启动

普罗米修斯默认配置文件 vim /usr/local/Prometheus/prometheus.yml

/usr/local/Prometheus/prometheus --config.file=/usr/local/Prometheus/prometheus.yml &
3、验证

浏览器打开IP:9090端口即可打开普罗米修斯自带的监控页面
在这里插入图片描述

四、安装Grafana

普罗米修斯默认的页面可能没有那么直观,我们可以安装grafana使监控看起来更直观

1、安装
rpm -ivh --nodeps grafana-5.4.2-1.x86_64.rpm
2、启动
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable grafana-server.service
sudo /bin/systemctl start grafana-server.service
3、访问grafana

浏览器访问IP:3000端口,即可打开grafana页面,默认用户名密码都是admin,初次登录会要求修改默认的登录密码
在这里插入图片描述
在这里插入图片描述

4、添加prometheus数据源

(1)点击主界面的“Add data source”
在这里插入图片描述
(2)选择Prometheus
在这里插入图片描述
(3)Dashboards页面选择“Prometheus 2.0 Stats”
在这里插入图片描述
(4)Settings页面填写普罗米修斯地址并保存
在这里插入图片描述
(5)切换到我们刚才添加的“Prometheus 2.0 Stats”即可看到整个监控页面
在这里插入图片描述

五、一些常用监控举例

1、监控linux机器(node-exporter)

https://github.com/prometheus/node_exporter/releases/download/v0.17.0/node_exporter-0.17.0.linux-amd64.tar.gz
(1)被监控的机器安装node-exporter

tar -xvf node_exporter-0.17.0.linux-amd64.tar.gz -C /usr/local/

(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

  • dashboard json
  • 链接:https://pan.baidu.com/s/1Dlm0IHTgRmc0q2P82cDjKg 提取码:myv6
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    修改名字,选择我们前文创建好的数据源,点击导入即可
    在这里插入图片描述
    如果没有任何显示,是grafana缺少相关显示需要用到的插件piechart,grafana的默认插件目录是/var/lib/grafana/plugins,可以将下载好的插件解压到这个目录,重启grafana即可
  • piechart插件:
  • 链接:https://pan.baidu.com/s/1tvZWI9vhAqvJhojKmDlmew 提取码:tlyl
service grafana-server restart
/usr/sbin/grafana-cli plugins ls  #查看已安装插件

在这里插入图片描述
再刷新grafana页面,即可看到我们刚才设置好的node监控
在这里插入图片描述

2、监控windows机器(wmi-exporter)

https://github.com/martinlindhe/wmi_exporter/releases
(1)被监控windows机器安装wmi-exporter,会自动创建一个开机自启的服务
在这里插入图片描述
在这里插入图片描述
(2)普罗米修斯配置文件添加配置项

vim /usr/local/Prometheus/prometheus.yml

默认wmi-exporter端口为9182

  - job_name: 'Prometheus'
    static_configs:
    - targets: ['192.168.0.102:9182']

重启普罗米修斯
(3)grafana导入画好的dashboard,选择普罗米修斯数据源

在这里插入图片描述
在这里插入图片描述

3、监控MySQL(mysqld-exporter)

https://github.com/prometheus/mysqld_exporter/releases/download/v0.11.0/mysqld_exporter-0.11.0.linux-amd64.tar.gz
(1)被监控mysql机器安装mysqld-exporter

tar -C /usr/local/ -xvf mysqld_exporter-0.11.0.linux-amd64.tar.gz

(2)设置配置文件,user为数据库登录用户,password为这个用户的密码

vi .my.cnf

[client]
user=root
password=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数据源即可

在这里插入图片描述

4、监控Redis(redis_exporter)

链接:https://pan.baidu.com/s/12y7HxtQlBjFwr_i8ClM8Kw 提取码:13v2
(1)安装redis_exporter

tar -C /usr/local/ -xvf redis_exporter-v0.15.0.linux-amd64.tar.gz

(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://javaforall.net/133204.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • linux 修改mysql端口「建议收藏」

    linux 修改mysql端口「建议收藏」1)先关闭MySQL的进程2)更改端口vim/etc/my.cnf添加:port=33083)重启MySQL服务:servicemysqldrestart4)查看MySQL的端口号3.1.登录mysqlmysql-uroot-p3.2.查看当前端口号showglobalvariableslike‘port’;…

    2022年10月3日
    1
  • pandas 0.23.4 :’pd.ewma’没有这个模块,改用`Series.ewm` 或 降低版本到 pandas 0.21.0

    pandas 0.23.4 :’pd.ewma’没有这个模块,改用`Series.ewm` 或 降低版本到 pandas 0.21.0问题:在进行画出指数平滑移动平均线,遇到如下问题:#pd.ewma(com=None,span=one)#指数平均线。com:数据;span:时间间隔AttributeError:module’pandas’hasnoattribute’ewma’解决办法:在pandas0.23.4版本中,已经不存在这种方法,回退到之前版本pandas0.21.0就一切完美…

    2025年7月12日
    2
  • pycharm设置代理_mac pycharm怎么设置环境

    pycharm设置代理_mac pycharm怎么设置环境一、Shadowsocket用默认端口即可不需要改二、mac网络三、Pycharm配置代理检测成功四、然而执行代码还是没走代理最后方式直接request加代理#!/usr/bin/evnpython#-*-coding:utf-8-*-importrequestsproxy={“http”…

    2022年8月26日
    5
  • 5分钟搞懂MySQL – 行转列

    5分钟搞懂MySQL – 行转列  MySQL行转列,对经常处理数据的同学们来说,一定是不陌生的,甚至是印象深刻,因为它大概率困扰到了你,让你为之一愣~但当你看到本文后,这个问题就不在是问题,及时收藏,以后谁再问你这个问题,直接甩他脸上,粘贴即用。

    2022年5月1日
    40
  • Mysql 日期格式转换

    Mysql 日期格式转换DATE_FORMAT(date,format)根据格式串format格式化日期或日期和时间值date,返回结果串。 可用DATE_FORMAT()来格式化DATE或DATETIME值,以便得到所希望的格式。根据format字符串格式化date值:

    2022年6月15日
    54
  • python用冒泡法排序_数组冒泡排序c语言函数

    python用冒泡法排序_数组冒泡排序c语言函数arr=[7,4,3,67,34,1,8].defbubble_sort:最近在学习Python,下面是我的一些笔记冒泡排序实现思路:使用双重for循环,内层变量为i,外层为j,在内层循环中不断的比较相邻的两个值(i,i+1)的大小,如果i+1的值大于i的值,交换两者位置,每循环一次,外层的j增加1,等到j等于n-1的时候,结束循环第一次看不懂很正常,不要灰心,下面是使用代码的实现arr=…

    2022年10月16日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号