No description
Find a file
2018-02-21 16:25:21 +11:00
.circleci Configure goreleaser and CircleCI to produce a docker image 2018-02-19 13:07:35 +11:00
cmd Set log level from environment variable PHP_FPM_LOG_LEVEL 2018-02-20 13:43:52 +11:00
phpfpm Add package documentation 2018-02-19 12:12:34 +11:00
test Update docker-compose example 2018-02-20 14:43:24 +11:00
.gitignore Add vendor and .idea directory to .gitignore 2018-02-18 21:58:14 +11:00
.goreleaser.yml Release binaries instead of archives 2018-02-21 16:25:21 +11:00
Dockerfile Remove USER nobody from Dockerfile 2018-02-19 16:30:40 +11:00
Gopkg.lock Swap glide with golang dep 2018-02-18 20:36:05 +11:00
Gopkg.toml Swap glide with golang dep 2018-02-18 20:36:05 +11:00
LICENSE Initial commit 2018-02-16 12:20:32 +11:00
main.go Add version information 2018-02-19 19:49:25 +11:00
README.md Add asciinema demo 2018-02-20 14:54:36 +11:00

php-fpm_exporter

CircleCI Go Report Card GoDoc Inline docs Maintainability Test Coverage

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!

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

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
--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

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
    

Docker Examples

  • Run docker manually

    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

    git clone git@github.com:hipages/php-fpm_exporter.git
    cd php-fpm_exporter/test
    docker-compose -p php-fpm_exporter up
    

    You can now access the following links:

    asciicast

Metrics collected

# HELP phpfpm_accepted_connections The number of requests accepted by the pool.
# TYPE phpfpm_accepted_connections counter
# HELP phpfpm_active_processes The number of active processes.
# TYPE phpfpm_active_processes gauge
# HELP phpfpm_idle_processes The number of idle processes.
# TYPE phpfpm_idle_processes gauge
# HELP phpfpm_listen_queue The number of requests in the queue of pending connections.
# TYPE phpfpm_listen_queue gauge
# HELP phpfpm_listen_queue_length The size of the socket queue of pending connections.
# TYPE phpfpm_listen_queue_length gauge
# HELP phpfpm_max_active_processes The maximum number of active processes since FPM has started.
# TYPE phpfpm_max_active_processes counter
# HELP phpfpm_max_children_reached The number of times, the process limit has been reached, when pm tries to start more children (works only for pm 'dynamic' and 'ondemand').
# TYPE phpfpm_max_children_reached counter
# HELP phpfpm_max_listen_queue The maximum number of requests in the queue of pending connections since FPM has started.
# TYPE phpfpm_max_listen_queue counter
# HELP phpfpm_slow_requests The number of requests that exceeded your 'request_slowlog_timeout' value.
# TYPE phpfpm_slow_requests counter
# HELP phpfpm_start_since The number of seconds since FPM has started.
# TYPE phpfpm_start_since counter
# HELP phpfpm_total_processes The number of idle + active processes.
# TYPE phpfpm_total_processes gauge

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.

Alternatives