我正在研究 Prometheus,我想将 PHP fpm 相关指标导出到 Prometheus。为此,我正在使用
https://github.com/Lusitaniae/phpfpm_exporter ,它在端口 9253 上提供服务。我可以从我想要共享指标的 pod 中确认该服务是否正常运行。
这是我的 prometheus.yml:
- job_name: 'phpfpm'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_container_name]
action: keep
regex: true
- source_labels: [__address__]
action: replace
regex: ([^:]+):.*
replacement: $1:9253
target_label: __address__
Pod 日志:
ps -ef | grep php
root 46 1 0 04:36 ? 00:00:00 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf)
root 48 46 0 04:36 ? 00:00:00 php-fpm: pool www
root 49 46 0 04:36 ? 00:00:00 php-fpm: pool www
root 86 1 0 04:36 ? 00:00:00 /usr/local/bin/phpfpm_exporter --phpfpm.socket-paths /var/run/php/php7.4-fpm.sock
root 93 62 0 04:36 ? 00:00:00 php /var/www/html/artisan --timeout=180 queue:work --sleep=3 --tries=3
root 148 127 0 04:48 pts/1 00:00:00 grep --color=auto php
root@auth-service-deployment-756c48d967-vpsnr:/var/www/html# less /var/run/php/php7.4-fpm.sock
/var/run/php/php7.4-fpm.sock is not a regular file (use -f to see it)
root@auth-service-deployment-756c48d967-vpsnr:/var/www/html# phpfpm_exporter --phpfpm.socket-paths /var/run/php/php7.4-fpm.sock
2021/03/02 04:48:31 Starting phpfpm_exporter (version=0.5.0, branch=HEAD, revision=9cb855b0e40f98db3bfae60d34d7b87834329310)
2021/03/02 04:48:31 Build context (go=go1.12.6, user=root@a53eecf46f97, date=20190621-12:09:02)
2021/03/02 04:48:31 Starting Server: :9253
但是当我在 Prometheus 中搜索 phpfpm 或 php_fpm 时,没有任何显示。我错过了什么?