Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

php-fpm_exporter

> 云原生
Open source

A prometheus exporter for PHP-FPM.

719 stars0 likes1 views
WebsiteGitHub

About

A prometheus exporter for PHP-FPM.

php-fpm_exporter

A prometheus exporter for PHP-FPM. The exporter connects directly to PHP-FPM and exports the metrics via HTTP.

A webserver such as NGINX or Apache is NOT needed!

Table of Contents

  • Features
  • Usage
    • Options and defaults
    • Why --phpfpm.fix-process-count?
    • CLI Examples
    • Docker Examples
    • Kubernetes Example
  • Metrics collected
  • Grafana Dasbhoard for Kubernetes
  • FAQ
  • Development
    • E2E Tests
  • Contributing
  • Contributors
  • Alternatives

Features

  • Export single or multiple pools
  • Export to CLI as text or JSON
  • Connects directly to PHP-FPM via TCP or Socket
  • Maps environment variables to CLI options
  • Fix for PHP-FPM metrics oddities
  • Grafana Dashboard for Kubernetes

Usage

php-fpm_exporter is released as binary and docker image. It uses sensible defaults which usually avoids the need to use command parameters or environment variables.

php-fpm_exporter supports 2 commands, get and server. The get command allows to retrieve information from PHP-FPM without running as a server and exposing an endpoint. The server command runs the server required for prometheus to retrieve the statistics.

Options and defaults

Option Description Environment variable Default value
--web.listen-address Address on which to expose metrics and web interface. PHP_FPM_WEB_LISTEN_ADDRESS :9253
--web.telemetry-path Path under which to expose metrics. PHP_FPM_WEB_TELEMETRY_PATH /metrics
--phpfpm.scrape-uri FastCGI address, e.g. unix:///tmp/php.sock;/status or tcp://127.0.0.1:9000/status PHP_FPM_SCRAPE_URI tcp://127.0.0.1:9000/status
--phpfpm.fix-process-count Enable to calculate process numbers via php-fpm_exporter since PHP-FPM sporadically reports wrong active/idle/total process numbers. PHP_FPM_FIX_PROCESS_COUNT false
--log.level Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal] (default "error") PHP_FPM_LOG_LEVEL info

Why --phpfpm.fix-process-count?

php-fpm_exporter implements an option to "fix" the reported metrics based on the provided processes list by PHP-FPM.

We have seen PHP-FPM provide metrics (e.g. active processes) which don't match reality. Specially active processes being larger than max_children and the actual number of running processes on the host. Looking briefly at the source code of PHP-FPM it appears a scoreboard is being kept and the values are increased/decreased once an action is executed. The metric active processes is also an accumulation of multiple states (e.g. Reading headers, Getting request information, Running). Which shouldn't matter and active processes should still be equal or lower to max_children.

--phpfpm.fix-process-count will emulate PHP-FPMs implementation including the accumulation of multiple states.

If you like to have a more granular reporting please use phpfpm_process_state.

  • https://bugs.php.net/bug.php?id=76003
  • https://stackoverflow.com/questions/48961556/can-active-processes-be-larger-than-max-children-for-php-fpm

CLI Examples

  • Retrieve information from PHP-FPM running on 127.0.0.1:9000 with status endpoint being /status

    php-fpm_exporter get
  • Retrieve information from PHP-FPM running on 127.0.0.1:9000 and 127.0.0.1:9001

    php-fpm_exporter get --phpfpm.scrape-uri tcp://127.0.0.1:9000/status,tcp://127.0.0.1:9001/status
  • Run as server with 2 pools:

    php-fpm_exporter server --phpfpm.scrape-uri tcp://127.0.0.1:9000/status,tcp://127.0.0.1:9001/status
  • Run as server and enable process count fix via environment variable:

    PHP_FPM_FIX_PROCESS_COUNT=1 go run main.go server --web.listen-address ":12345" --log.level=debug

Docker Examples

  • Run docker manually

    bash
    docker pull hipages/php-fpm_exporter
    docker run -it --rm -e PHP_FPM_SCRAPE_URI="tcp://127.0.0.1:9000/status,tcp://127.0.0.1:9001/status" hipages/php-fpm_exporter
  • Run the docker-compose example

    bash
    git clone [email protected]:hipages/php-fpm_exporter.git
    cd php-fpm_exporter/test
    docker-compose -p php-fpm_exporter up

    You can now access the following links:

    • Prometheus: http://127.0.0.1:9090/
    • php-fpm_exporter metrics: http://127.0.0.1:9253/metrics

Kubernetes Example

TBD

Metrics collected

…

Grafana Dasbhoard for Kubernetes

The Grafana dashboard can be found here. There is also a more generic version here.

FAQ

  • How to update "Metrics collected"?

    Copy&paste the output from:

    bash
    curl http://127.0.0.1:12345/metrics | grep phpfpm | grep "#"

Development

E2E Tests

The E2E tests are based on docker-compose and bats-core. Install the required components, e.g. via brew on MacOS:

bash
brew tap kaos/shell
brew install docker-compose bats-core kaos/shell/bats-assert kaos/shell/bats-support

After the components are installed run the E2E tests:

bash
make test-e2e

Contributing

Contributions are greatly appreciated. The maintainers actively manage the issues list, and try to highlight issues suitable for newcomers. The project follows the typical GitHub pull request model. See " How to Contribute to Open Source " for more details. Before starting any work, please either comment on an existing issue, or file a new one.

Contributors

Thanks goes to these wonderful people (emoji key):

Enrico Stahn ⚠️

Stanislav Antic

herb

Smoked Cheese

Alexander

Stan Xing

itcsoft54

John S Long

Daniel O'Callaghan

Simon Stücher

André Sterba

This project follows the all-contributors specification. Contributions of any kind welcome!

Stargazers over time

Alternatives

  • bakins/php-fpm-exporter
  • peakgames/php-fpm-prometheus
  • craigmj/phpfpm_exporter

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Gogolangphp-fpmprometheusprometheus-exporter

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category云原生
PricingOpen source

> Related tools

K
Kubernetes
容器编排事实标准
H
Helm
Kubernetes 包管理器
S
seaweedfs
SeaweedFS is a distributed storage system for object storage (S3), file systems, and Iceberg tables,