广告
返回顶部
首页 > 资讯 > 后端开发 > PHP编程 >Prometheus监控PHP应用
  • 616
分享到

Prometheus监控PHP应用

phpprometheus服务器 2023-08-31 20:08:43 616人浏览 泡泡鱼
摘要

文章目录 1、配置PHP-FPM,暴露php-fpm状态信息2、bakins/php-fpm-exporter监控PHP应用2.1、配置php状态页的http访问2.2、下载bakins/ph

文章目录

监控PHP状态信息,必须先配置显示php状态页,这样prometheus才能通过Exporter进行监控。

1、配置PHP-FPM,暴露php-fpm状态信息

官方参考:https://easyengine.io/tutorials/php/fpm-status-page/
修改/usr/local/php/etc/php-fpm.conf,增加以下内容

pm.status_path = /statusping.path = /ping

目前可用于监控PHP的Exporter有三个:

本文只介绍前边两个

2、bakins/php-fpm-exporter监控PHP应用

bakins/php-fpm-exporter只能通过Http读取PHP状态页信息,需要借助Nginx来提供PHP状态页数据

2.1、配置php状态页的http访问

nginx.conf

server {    listen 9010;     allow 127.0.0.1;   #限制ip    allow 192.168.28.131;   #限制ip    deny all;    location ~ ^/(status|ping)$ {        fastcgi_pass  unix:/tmp/php-cgi.sock; # unix Socket        #fastcgi_pass 127.0.0.1:9000;         # tcp        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;        include fastcgi_params;    }}

查看状态页数据

[root@ ~]# curl http://127.0.0.1:9010/status# php-fpm状态页的内容如下pool:                 wwwprocess manager:      dynamicstart time:           24/Sep/2022:22:50:44 +0800start since:          2219accepted conn:        42listen queue:         0max listen queue:     0listen queue len:     0idle processes:       12active processes:     1total processes:      13max active processes: 5max children reached: 0slow requests:        0

2.2、下载bakins/php-fpm-exporter

下载地址:https://github.com/bakins/php-fpm-exporter
下载文件:php-fpm-exporter.linux.amd64

mv php-fpm-exporter.linux.amd64 /usr/local/php-fpm-exporterchmod u+x /usr/local/php-fpm-exporter# php-fpm-exporter命令参数usage: php-fpm-exporter []Flags:  -h, --help                   Show context-sensitive help (also try --help-long and --help-man).      --addr="127.0.0.1:8080"  listen address for metrics handler      --endpoint="http://127.0.0.1:9000/status"  url for php-fpm status      --fastcgi=FASTCGI        fastcgi url. If this is set, fastcgi will be used instead of HTTP      --WEB.telemetry-path="/metrics"   Path under which to expose metrics. Cannot be /# 运行/usr/local/php-fpm-exporter --addr 0.0.0.0:9011 --endpoint="http://127.0.0.1:9010/status" --web.telemetry-path="/metrics"

查看转成Prometheus监控指标的状态页数据

[root@s2 ~]# curl http://127.0.0.1:9011/metrics

2.3、配置为系统服务

vi /usr/lib/systemd/system/php_exporter.service

[Unit]Description=php_exporterWants=network-online.targetAfter=network-online.target[Service]User=rootGroup=rootType=simpleExecStart=/usr/local/php-fpm-exporter \    --addr=0.0.0.0:9011 \    --endpoint=http://127.0.0.1:9010/status \    --web.telemetry-path=/metrics[Install]WantedBy=multi-user.target

php_exporter服务命令

systemctl daemon-reload       # 通知systemd重新加载配置文件systemctl enable php_exporter   # 设置开机启动systemctl disable php_exporter  # 取消开机启动systemctl start php_exporter    # 启动服务systemctl restart php_exporter  # 重启服务systemctl stop php_exporter     # 关闭服务systemctl status php_exporter   # 查看状态

2.4、配置防火墙

如果端口未开启,需要开启相关端口

#启动防火墙systemctl start firewalld.service#开通端口firewall-cmd --zone=public --add-port=9011/tcp --permanent#重启防火墙firewall-cmd --reload

2.5、与Prometheus集成

prometheus.yml

scrape_configs:  - job_name: 'PHP-FPM'    static_configs:      - targets: ['192.168.28.132:9011','192.168.28.136:9011']

重新加载配置

curl -X POST  http://127.0.0.1:9090/-/reload   # prmetheus不需要登录 curl -X POST  http://admin@123456:127.0.0.1:9090/-/reload  # prmetheus需要登录

在这里插入图片描述

在这里插入图片描述

2.6、与Grafana集成

可视化模板:https://grafana.com/grafana/dashboards/3901-php-fpm/
在这里插入图片描述

3、hipages/php-fpm_exporter监控php应用

3.1、下载

下载:https://github.com/hipages/php-fpm_exporter
下载文件:php-fpm_exporter_2.2.0_linux_amd64

mv php-fpm_exporter_2.2.0_linux_amd64 /usr/local/php-fpm_exporterchmod u+x /usr/local/php-fpm_exporter# 运行命令有两个# get方式是在命令行下显示结果 sudo -u www /usr/local/php-fpm_exporter get --phpfpm.scrape-uri "unix:///tmp/php-cgi.sock;/status"# server方式是以web方式示结果sudo -u www /usr/local/php-fpm_exporter server --web.listen-address ":9253" --phpfpm.scrape-uri "unix:///tmp/php-cgi.sock;/status"# web方式示结果查看监控数据curl http://127.0.0.1:9253/metrics

3.2、配置为系统服务

vi /usr/lib/systemd/system/php_exporter2.service

[Unit]Description=php_exporter2Wants=network-online.targetAfter=network-online.target[Service]User=wwwGroup=wwwType=simpleExecStart=/usr/local/php-fpm_exporter server \    --web.listen-address ":9253" \    --web.telemetry-path "/metrics" \    --phpfpm.scrape-uri "unix:///tmp/php-cgi.sock;/status"#    --phpfpm.scrape-uri "tcp://127.0.0.1:9000/status"[Install]WantedBy=multi-user.target

php_exporter2服务命令

systemctl daemon-reload       # 通知systemd重新加载配置文件systemctl enable php_exporter2   # 设置开机启动systemctl disable php_exporter2  # 取消开机启动systemctl start php_exporter2    # 启动服务systemctl restart php_exporter2  # 重启服务systemctl stop php_exporter2     # 关闭服务systemctl status php_exporter2   # 查看状态

vi /etc/passwd

www:x:1002:1002::/home/www:/sbin/nologin# 修改为www:x:1002:1002::/home/www:/bin/bash

3.3、与Prometheus集成

scrape_configs:  - job_name: 'PHP-FPM2'    static_configs:      - targets: ['192.168.28.136:9253']        labels:          namespace: '192.168.28.136:9253'      - targets: ['192.168.28.132:9253']        labels:          namespace: '192.168.28.132:9253'

在这里插入图片描述

在这里插入图片描述

3.4、与Grafana集成

可视化模板:https://grafana.com/grafana/dashboards/15796-php-fpm/
在这里插入图片描述

来源地址:https://blog.csdn.net/penngo/article/details/127045590

--结束END--

本文标题: Prometheus监控PHP应用

本文链接: https://www.lsjlt.com/news/386828.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Prometheus监控PHP应用
    文章目录 1、配置PHP-FPM,暴露php-fpm状态信息2、bakins/php-fpm-exporter监控PHP应用2.1、配置php状态页的http访问2.2、下载bakins/ph...
    99+
    2023-08-31
    php prometheus 服务器
  • Prometheus监控PHP-FPM
    启用php-fpm状态功能php-fpm和nginx一样内建了一个状态页,对于想了解php-fpm的状态以及监控php-fpm非常有帮助。为了后续的Prometheus监控,我们需要先了解php-fpm状态页是怎么回事。在上一篇文章中,已经...
    99+
    2023-01-31
    Prometheus PHP FPM
  • prometheus 监控docker
    cAdvisor(Container Advisor)用于收集正在运行的容器资源使用和性能信息。使用Prometheus监控cAdvisorcAdvisor将容器统计信息公开为Prometheus指标。默认情况下,这些指标在/metrics...
    99+
    2023-01-31
    prometheus docker
  • 使用Prometheus+Grafana监控JVM
    JMX Exporterhttps://github.com/prometheus/jmx_exporter它是Prometheus官方组件,作为一个JAVA Agent来提供本地JVM的metrics,并通过http暴露出来。这也是官方推...
    99+
    2023-01-31
    Prometheus Grafana JVM
  • 【无监控,不运维】监控之Prometheus
    文章目录 一、常用监控简介1.cacti2.Nagios3.Zabbix3.1 zabbix的构成3.2 zabbix的优点和缺点3.3 zabbix核心组件介绍 二、Prometh...
    99+
    2023-09-01
    运维 prometheus php
  • Prometheus分布式监控
    prometheus安装在阿里云上面,监控节点在公司内部机房,2个网络直接是不互通的。环境说明阿里云服务器:操作系统:centos 7.6数量:1台 公司内部服务器操作系统:centos 7.6数量:1台 拓扑图&nbs...
    99+
    2023-01-31
    分布式 Prometheus
  • Prometheus MySQL 性能监控
    一、 介绍 Prometheus 是一种开源的监控系统和时序数据库,旨在收集和处理大量数据并提供可视化、监控警报等功能。它支持多种语言、多种部署方式,并且非常灵活,而且社区支持非常活跃,为用户提供了很...
    99+
    2023-09-01
    mysql prometheus 数据库
  • 利用Prometheus和Grafana监控MySQL
     一、 Prometheus 是一个开源的服务监控系统和时间序列数据库。:官方GitHub地址为:https://github.com/prometheus/prometheus 官方地...
    99+
    2022-10-18
  • SpringBoot如何使用prometheus监控
    这篇文章主要介绍SpringBoot如何使用prometheus监控,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!1.关于PrometheusPrometheus是一个根据应用的metrics来进行监控的开源工具。相...
    99+
    2023-06-14
  • prometheus监控nginx的实现
    目录简述1.下载nginx-module-vts模块2.安装nginx3.安装nginx-vts-exporter4.修改prometheus-cfg.yaml文件5.在grafan...
    99+
    2022-11-13
  • prometheus+grafana如何监控nginx
    这篇文章主要介绍prometheus+grafana如何监控nginx,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!在prometheus需要向ngxin中打入探针,通过探针获取ngxin信息,并通过接口输出。下文将...
    99+
    2023-06-21
  • grafana、prometheus监控linux、mysql等
    监控安装部署 监控安装下载所需包:  下载地址:Download | Prometheus Grafana下载 官网下载Download Grafana | Grafana Labs(速度较慢) 国内镜像Grafana 国内加速下载 | ...
    99+
    2023-08-31
    linux mysql grafana prometheus
  • Prometheus 监控MySQL使用grafana展示
    目录prometheus通过exporter监控mysql,并用grafana图表展示1、测试机器 2、配置mysql host013、创建exporter帐号4、下载,安...
    99+
    2022-11-12
  • prometheus client_go为应用程序自定义监控指标
    目录使用prometheus client_go为应用程序添加监控指标原因去掉Proc和Go指标使用prometheus client_go为应用程序添加监控指标 使用promet...
    99+
    2023-02-15
    prometheus client_go监控指标 go监控指标
  • Prometheus、Alertmanager、Grafana 监控 Linux 与 MySQL
    //检查各个端口的放行 //部署各个模块与应用 cd /usr/local/Prometheus_compose vim docker-compose.yml version: "3" services: prom: imag...
    99+
    2017-01-04
    Prometheus Alertmanager Grafana 监控 Linux MySQL 数据库入门 数据库基础教程 数据库 mysql
  • Prometheus如何监控Springboot程序
    这篇文章主要介绍Prometheus如何监控Springboot程序,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!1. 添加依赖我本次使用的Springboot版本为1.5.12.RELEASE,如果是Springb...
    99+
    2023-06-14
  • Prometheus监控运维实战十: 主机监控指标
    1、CPU指标 CPU负载 node_load1node_load5node_load15 以上三个指标为主机的CPU平均负载,分别对应一分钟、五分钟和十五分钟的时间间隔。CPU负载是指某段时间内占用...
    99+
    2023-09-12
    运维 prometheus 服务器
  • Grafana+Prometheus如何监控MySql服务
    这篇文章主要为大家展示了“Grafana+Prometheus如何监控MySql服务”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“Grafana+Prometh...
    99+
    2022-10-18
  • SpringBoot使用prometheus监控的示例代码
    目录1.关于Prometheus2.有关Grafana3.SpringBoot使用Prometheus3.1 依赖内容3.2 配置文件3.3 设置application4.Prome...
    99+
    2022-11-11
  • Python调用Prometheus监控数据并计算
    目录Prometheus是什么Prometheus基础概念什么是时间序列数据什么是targets(目标)什么是metrics(指标)什么是PromQL(函数式查询语言)如何监控远程L...
    99+
    2022-11-12
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作