1. 环境
- php-fpm-exporter.linux.amd64
php-fpm-exporter 用来收集机器的php 指标
2. 准备条件
2.1 PHP-FPM端
# vim /etc/php-fpm.d/www.conf
pm.status_path = /status
ping.path = /ping
# 重启php-fpm
systemctl restart php-fpm
2.1 Nginx端
# vim /etc/nginx/conf.d/php-fpm-status.conf
server {
listen 9010;
allow 127.0.0.1;
deny all;
location ~ ^/(status|ping)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
# 加载配置
systemctl reload nginx
2.3 PHP-FPM-exporter端
一般情况下, php-fpm-exporter 与 php-fpm 在同一个机器上
# 下载php-fpm-exporter --> https://github.com/bakins/php-fpm-exporter/releases
wget https://github.com/bakins/php-fpm-exporter/releases/download/v0.6.1/php-fpm-exporter.linux.amd64 -O /usr/local/src/php-fpm-exporter
chmod +x /usr/local/src/php-fpm-exporter
# 启动 php-fpm-exporter
nohup /usr/local/src/php-fpm-exporter --addr 0.0.0.0:9190 --endpoint http://127.0.0.1:9010/status &> /dev/null &
2.4 Prometheus端
- job_name: php-fpm
static_configs:
- targets: ['<host>:<port>']
labels:
instance: PRODUCT-NAME