首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >Promethues如何监控PHP

Promethues如何监控PHP

作者头像
Linux运维技术之路
发布2022-06-07 09:06:59
发布2022-06-07 09:06:59
1.9K0
举报

利用php-fpm-exporter对php-fpm进行监控

  • 1、php-fpm开启status接口
  • 2、nginx代理php-fpm接口
  • 3、使用php-fpm-exporter暴露指标给Prometheus
  • 4、granfna展示

一、 php-fpm 开启status接口

需要提前安装好php,和nginx 环境

  • 1、 找到php配置文件,修改配置,开启status vim /usr/local/php/etc/php-fpm.conf
代码语言:javascript
复制
...
pm.status_path = /status
ping.path = /ping
...

  • 2、 配置nginx
代码语言:javascript
复制
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;
        }
}
  • 3、检查status是否可以访问
代码语言:javascript
复制
[root@Prometheus conf]#  curl http://127.0.0.1:9010/status
pool:                 www
process manager:      dynamic
start time:           23/Feb/2020:11:54:50 +0800
start since:          10626
accepted conn:        1
listen queue:         0
max listen queue:     0
listen queue len:     128
idle processes:       14
active processes:     1
total processes:      15
max active processes: 1
max children reached: 0
slow requests:        0

二、 使用php-fpm-exporter暴露指标

  • 1、下载php-fpm-exporter,并启动
代码语言:javascript
复制
wget https://github.com/bakins/php-fpm-exporter/releases/download/v0.6.1/php-fpm-exporter.linux.amd64
mkdir -p /usr/local/exporter/php-fpm/
mv php-fpm-exporter.linux.amd64 /usr/local/exporter/php-fpm/php-fpm-exporter
nohup /usr/local/exporter/php-fpm/php-fpm-exporter --addr 0.0.0.0:9190 --endpoint http://127.0.0.1:9010/status &
  • 2、检查metrics是否可以访问
代码语言:javascript
复制
[root@Prometheus php-fpm]# curl 127.0.0.1:9190/metrics
# HELP phpfpm_accepted_connections_total Total number of accepted connections
# TYPE phpfpm_accepted_connections_total counter
phpfpm_accepted_connections_total 4
# HELP phpfpm_active_max_processes Maximum active process count
# TYPE phpfpm_active_max_processes counter
phpfpm_active_max_processes 1
# HELP phpfpm_listen_queue_connections Number of connections that have been initiated but not yet accepted
# TYPE phpfpm_listen_queue_connections gauge
phpfpm_listen_queue_connections 0
# HELP phpfpm_listen_queue_length_connections The length of the socket queue, dictating maximum number of pending connections
# TYPE phpfpm_listen_queue_length_connections gauge
phpfpm_listen_queue_length_connections 128
# HELP phpfpm_listen_queue_max_connections Max number of connections the listen queue has reached since FPM start
# TYPE phpfpm_listen_queue_max_connections counter
phpfpm_listen_queue_max_connections 0
# HELP phpfpm_max_children_reached_total Number of times the process limit has been reached
# TYPE phpfpm_max_children_reached_total counter
phpfpm_max_children_reached_total 0
# HELP phpfpm_processes_total process count
# TYPE phpfpm_processes_total gauge
phpfpm_processes_total{state="active"} 1
phpfpm_processes_total{state="idle"} 14
# HELP phpfpm_scrape_failures_total Number of errors while scraping php_fpm
# TYPE phpfpm_scrape_failures_total counter
phpfpm_scrape_failures_total 0
# HELP phpfpm_slow_requests_total Number of requests that exceed request_slowlog_timeout
# TYPE phpfpm_slow_requests_total counter
phpfpm_slow_requests_total 0
# HELP phpfpm_up able to contact php-fpm
# TYPE phpfpm_up gauge
phpfpm_up 1
  • web 访问

三、配置promethus,采集php-fpm的数据

vim /usr/local/promethus/promethus.yml

代码语言:javascript
复制
  - job_name: 'php-fpm'
    static_configs:
    - targets:
      - 114.67.116.119:9190

四、配置granfna进行数据展示

配置导入,3901模板

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2020-07-12,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Linux运维技术之路 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 利用php-fpm-exporter对php-fpm进行监控
  • 一、 php-fpm 开启status接口
  • 二、 使用php-fpm-exporter暴露指标
  • 三、配置promethus,采集php-fpm的数据
  • 四、配置granfna进行数据展示
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档