常用 Exporter 部署
· 阅读需 3 分钟
常用 Exporter 部署
Node-exporter 部署
# 下载安装包
wget https://github.com/prometheus/node_exporter/releases/download/v1.1.2/node_exporter-1.1.2.linux-amd64.tar.gz
# 进入程序目录
tar xf node_exporter-1.1.2.linux-amd64.tar.gz
mv node_exporter-1.1.2.linux-amd64 node_exporter-1.1.2
cd node_exporter-1.1.2
# 放入后台启动
nohup ./node_exporter &
Prometheus 配置修改
- job_name: 'node-exporter'
static_configs:
- targets: ['localhost:9100','192.168.2.90:9100','192.168.2.164:9100']
Grafana 配置图标
https://grafana.com/grafana/dashboards/8919

Mysql-exporter 部署
宿主机 mysql-client 下载
# 由于不想在mysql容器中安装exporter,所以在宿主机安装 mysql client
yum install mysql-community-client.x86_64 -y
# 出现报错:
Public key for mysql-community-client-5.7.39-1.el7.x86_64.rpm is not installed
Failing package is: mysql-community-client-5.7.39-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
# Mysql的GPG升级了,需要重新获取
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum install mysql-community-client.x86_64 -y
下载 Mysql_export
wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz
tar -zxvf mysqld_exporter-0.12.1.linux-amd64.tar.gz
mv mysqld_exporter-0.12.1.linux-amd64 mysqld_exporter-0.12.1
# 现在有更新版本了,没有验证是否支持 mysql8.0,只验证了5.7
创建连接数据库的配置文件
cd mysqld_exporter-0.12.1
vim my.cnf
[client]
host=192.168.2.90
port=3306
user=root
password=obcijV6j5BjvLLB8gJZpUC6aho
启动服务
./mysqld_exporter --config.my-cnf="./my.cnf"
# 验证:-》浏览器
ip:9104
Prometheus 配置修改
- job_name: 'mysql-exporter'
static_configs:
- targets: ['192.168.2.90:9104']
# 重启 Prometheus,加载配置
grafana 配置图表
地址: https://grafana.com/grafana/dashboards/11323
Redis_exporter 部署
https://github.com/oliver006/redis_exporter/releases/download/v1.43.1/redis_exporter-v1.43.1.linux-amd64.tar.gz
tar xf redis_exporter-v1.43.1.linux-amd64.tar.gz
mv redis_exporter-v1.43.1.linux-amd64 redis_exporter
cd redis_exporter
配置启动脚本
[root@csm redis_exporter]# cat start.sh
#!/bin/bash
nohup ./redis_exporter -redis.addr 192.168.2.90:6379 &
# -redis.password "ft7fc0sCnuImNY47OtFErVwRLIM=" &
# 启动
sh start.sh
Prometheus 配置修改
- job_name: 'redis-exporter'
static_configs:
- targets:
- redis://154.39.148.118:6379
metrics_path: /metrics
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 154.39.148.118:9121
Grafana
# 地址: https://github.com/oliver006/redis_exporter
# grafana_prometheus_redis_dashboard.json:
https://github.com/oliver006/redis_exporter/blob/master/contrib/grafana_prometheus_redis_dashboard.json
Rabbitmq 部署
wget https://github.com/kbudde/rabbitmq_exporter/releases/download/v1.0.0-RC19/rabbitmq_exporter_1.0.0-RC19_linux_amd64.tar.gz
tar xf rabbitmq_exporter_1.0.0-RC19_linux_amd64.tar.gz
mv rabbitmq_exporter_1.0.0-RC19_linux_amd64 rabbitmq_exporter_1.0.0
cd rabbitmq_exporter_1.0.0
启动 export
RABBIT_USER=root RABBIT_PASSWORD=123456 OUTPUT_FORMAT=JSON RABBIT_URL=http://192.168.2.90:15672 ./rabbitmq_exporter &
exit
Prometheus 配置添加
- job_name: 'rabbitmq-exporter'
static_configs:
- targets: ['192.168.2.90:9419']
Grafana
# 单节点的要用这个ID
4371