grafana-prometheus-php-fpm
公司新項目需要增加PHP伺服器的監控,是以自己百度搞了一套,整理一下,記錄下來,利用php-fpm自帶的狀态頁實作。
nginx
需要配置nginx.conf内容如下
server {
listen 9010;
location ~ ^/(status|ping)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
通過NGINX去定向解析php-fpm的狀态頁。
PHP-FPM
找到php-fpm所在的配置檔案www.conf 添加内容如下
pm.status_path = /status
ping.path = /ping
重新開機php-fpm
systemctl restart php-fpm
PHP-FPM-EXPORTER
下載下傳與prometheus搭配使用的php-fpm-exporter
- 下載下傳位址
wget https://github.com/bakins/php-fpm-exporter/releases/download/v0.6.1/php-fpm-exporter.linux.amd64
- 部署
mkdir -p /usr/local/prometheus
mv ./php-fpm-exporter.linux.amd64 /usr/local/prometheus
chown +x /usr/local/prometheus/php-fpm-exporter.linux.amd64
- 啟動
配置promethues
找到啟動promethues的配置檔案promethues.yml
修改内容如下
- job_name: 'PHP-FPM'
static_configs:
- targets:
- 127.0.0.1:9190
重新開機promethues
systemctl restart promethues.server
- 檢視配置的狀态
State Up OK
grafana配置圖表
推薦圖表位址
https://grafana.com/dashboards/3901php-fpm圖表
直接import 導入 3901
完成!
友情連結:
- grafana圖表位址:https://grafana.com/grafana/dashboards?dataSource=prometheus
- promethues擴充位址:https://prometheus.io/download/