prometheus和grafana安装

prometheus和grafana安装

    • 安装包获取
      • prometheus安装包
      • grafana安装包-阿里云
      • grafana仪表盘
      • grafana仪表盘-mysql
    • 解压安装prometheus
      • node_exporter
      • mysqld_exporter
      • prometheus
    • 网页查看
      • 网页查看prometheus
      • 网页查看node_exporter
      • 网页查看mysqld_exporter
    • 解压安装grafana
      • 服务器安装grafana
      • 网页配置grafana
        • 添加数据源
        • 添加仪表板
        • 查看仪表板

安装包获取

prometheus安装包

prometheus和grafana安装_第1张图片

grafana安装包-阿里云

prometheus和grafana安装_第2张图片

grafana仪表盘

prometheus和grafana安装_第3张图片
prometheus和grafana安装_第4张图片

grafana仪表盘-mysql

prometheus和grafana安装_第5张图片
prometheus和grafana安装_第6张图片

解压安装prometheus

  • blackbox_exporter
  • alertmanager
  • graphite_exporter
  • mysqld_exporter
  • node_exporter
  • prometheus
  • pushgateway
[root@docker-p-g prometheus]# ll
总用量 176964
-rw-r--r-- 1 root root 29254678 326 10:37 alertmanager-0.25.0.linux-amd64.tar.gz
drwxr-xr-x 2 3434 3434      109 326 10:48 blackbox_exporter-0.23.0.linux-amd64
-rw-r--r-- 1 root root 10831812 326 10:37 blackbox_exporter-0.23.0.linux-amd64.tar.gz
-rw-r--r-- 1 root root 14688607 326 10:37 graphite_exporter-0.13.3.linux-amd64.tar.gz
drwxr-xr-x 2 3434 3434      129 326 12:01 mysqld_exporter-0.14.0.linux-amd64
-rw-r--r-- 1 root root  7450991 326 10:53 mysqld_exporter-0.14.0.linux-amd64 (1).tar.gz
drwxr-xr-x 2 3434 3434       81 326 10:49 node_exporter-1.5.0.linux-amd64
-rw-r--r-- 1 root root 10181045 326 10:46 node_exporter-1.5.0.linux-amd64.tar.gz
drwxr-xr-x 5 1001  123      190 326 12:09 prometheus-2.43.0.linux-amd64
-rw-r--r-- 1 root root 91091544 326 10:37 prometheus-2.43.0.linux-amd64.tar.gz
drwxr-xr-x 2 3434 3434       77 326 10:50 pushgateway-1.5.1.linux-amd64
-rw-r--r-- 1 root root 10051993 326 10:37 pushgateway-1.5.1.linux-amd64.tar.gz
-rw-r--r-- 1 root root  7636153 326 10:37 statsd_exporter-0.23.1.linux-amd64.tar.gz

node_exporter

cd node_exporter-1.5.0.linux-amd64;ll
echo "nohup ./node_exporter > node_exporter.log 2>&1 &" > node_exporter.start
chmod a+x node_exporter.start
./node_exporter.start
[root@docker-p-g node_exporter-1.5.0.linux-amd64]# ps -ef | grep node_exporter
root       1750   1274  0 10:49 pts/0    00:00:04 ./node_exporter
root      13147   1274  0 12:35 pts/0    00:00:00 grep --color=auto node_exporter
#默认运行在9100
[root@docker-p-g node_exporter-1.5.0.linux-amd64]# ss -utnlp | grep 1750
tcp    LISTEN     0      128      :::9100                 :::*                   users:(("node_exporter",pid=1750,fd=3))

mysqld_exporter

mysql内授权

mysql> create user 'exporter'@'%' identified by 'zzz-123-ZZZ';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'%'  WITH MAX_USER_CONNECTIONS 3;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

配置mysqld_exporter连接数据库
mysqld_exporter运行时默认读取运行用户家目录下的.my.cnf文件
笔者用的root用户
配置.my.cnf文件
参考1
参考2

vim /root/.my.cnf
[client]
host=192.168.44.180
port=3306
user=exporter
password=zzz-123-ZZZ

配置运行mysqld_exporter

cd mysqld_exporter-0.14.0.linux-amd64
echo "nohup ./mysqld_exporter > mysqld_exporter.log 2>&1 &" > mysqld_exporter.start
chmod a+x mysqld_exporter.start
./mysqld_exporter.start
[root@docker-p-g mysqld_exporter-0.14.0.linux-amd64]# ps -ef | grep mysqld_exporter
root      13051      1  0 12:07 pts/1    00:00:06 ./mysqld_exporter
root      13190   1839  0 12:47 pts/1    00:00:00 grep --color=auto mysqld_exporter
#mysqld_exporter默认为9104
[root@docker-p-g mysqld_exporter-0.14.0.linux-amd64]# ss -utnlp | grep 13051
tcp    LISTEN     0      128      :::9104                 :::*                   users:(("mysqld_exporter",pid=13051,fd=3))

prometheus

cd prometheus-2.43.0.linux-amd64
vim prometheus.yml

新增exporter配置

  - job_name: "node_local"
    static_configs:
      - targets: ["localhost:9100"]
  - job_name: "mysql_local"
    static_configs:
      - targets: ["localhost:9104"]
echo "nohup ./prometheus > prometheus.log 2>&1 &" > prometheus.start
./prometheus.start
[root@docker-p-g prometheus-2.43.0.linux-amd64]# ps -ef | grep prometheus
root      13068      1  0 12:09 pts/0    00:00:03 ./prometheus
root      13206   1839  0 12:53 pts/1    00:00:00 grep --color=auto prometheus
#prometheus默认9090
[root@docker-p-g prometheus-2.43.0.linux-amd64]# ss -utnlp | grep 13068
tcp    LISTEN     0      128      :::9090                 :::*                   users:(("prometheus",pid=13068,fd=7))

网页查看

网页查看prometheus

http://192.168.44.180:9090
prometheus和grafana安装_第7张图片
prometheus和grafana安装_第8张图片
prometheus和grafana安装_第9张图片
prometheus和grafana安装_第10张图片

网页查看node_exporter

http://192.168.44.180:9100/metrics
prometheus和grafana安装_第11张图片

网页查看mysqld_exporter

http://192.168.44.180:9104/metrics
prometheus和grafana安装_第12张图片

解压安装grafana

服务器安装grafana

[root@docker-p-g prometheus-2.43.0.linux-amd64]# cd /data/grafana/
[root@docker-p-g grafana]# ll
总用量 77584
-rw-r--r-- 1 root root 79444031 326 11:08 grafana-9.0.0-1.x86_64.rpm
[root@docker-p-g grafana]# yum -y install grafana-9.0.0-1.x86_64.rpm
[root@docker-p-g grafana]# systemctl start grafana-server.service
[root@docker-p-g grafana]# systemctl status grafana-server.service
● grafana-server.service - Grafana instance
   Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; disabled; vendor preset: disabled)
   Active: active (running) since 日 2023-03-26 11:13:09 CST; 1h 49min ago
     Docs: http://docs.grafana.org
 Main PID: 2526 (grafana-server)
   CGroup: /system.slice/grafana-server.service
           └─2526 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/var/run/grafana/grafana-server.pid --packaging=rpm cfg:default.paths.log...

326 12:12:55 docker-p-g grafana-server[2526]: logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2023-03-26T12:12:55.255...
326 12:13:05 docker-p-g grafana-server[2526]: logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2023-03-26T12:...000000000
326 12:13:05 docker-p-g grafana-server[2526]: logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2023-03-26T12:13:05.490...
326 12:13:05 docker-p-g grafana-server[2526]: logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2023-03-26T12:...000000000
326 12:13:05 docker-p-g grafana-server[2526]: logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2023-03-26T12:13:05.506...
326 12:13:09 docker-p-g grafana-server[2526]: logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2023-03-26T12:...000000000
326 12:13:09 docker-p-g grafana-server[2526]: logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2023-03-26T12:13:09.902...
326 12:13:10 docker-p-g grafana-server[2526]: logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2023-03-26T12:13:10.172...
326 12:13:10 docker-p-g grafana-server[2526]: logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2023-03-26T12:13:10.191...
326 12:13:10 docker-p-g grafana-server[2526]: logger=live t=2023-03-26T12:13:10.203636377+08:00 level=info msg="Initialized channel handler" channe...rYdddlPWk
Hint: Some lines were ellipsized, use -l to show in full.
#grafana默认3000
[root@docker-p-g grafana]# ss -utnlp | grep 2526
tcp    LISTEN     0      128      :::3000                 :::*                   users:(("grafana-server",pid=2526,fd=14))

网页配置grafana

默认admin/admin

添加数据源

prometheus和grafana安装_第13张图片
prometheus和grafana安装_第14张图片
prometheus和grafana安装_第15张图片

添加仪表板

prometheus和grafana安装_第16张图片
prometheus和grafana安装_第17张图片
prometheus和grafana安装_第18张图片
prometheus和grafana安装_第19张图片

查看仪表板

prometheus和grafana安装_第20张图片
prometheus和grafana安装_第21张图片

你可能感兴趣的:(prometheus,grafana,linux)