The Service Map for APM is here!

PHP FPM

Agent Check Agent Check

Supported OS: Linux Mac OS Windows

PHP overview

Overview

The PHP-FPM check monitors the state of your FPM pool and tracks request performance.

Setup

Installation

The PHP-FPM check is included in the Datadog Agent package, so you don’t need to install anything else on your servers that use PHP-FPM.

Configuration

Edit the php_fpm.d/conf.yaml file, in the conf.d/ folder at the root of your Agent’s configuration directory. See the sample php_fpm.d/conf.yaml for all available configuration options:

init_config:

instances:
  - status_url: http://localhost/status # or whatever pm.status_path is set to in your PHP INI
    ping_url: http://localhost/ping     # or whatever ping.path is set to in your PHP INI
    ping_reply: pong                    # the reply to expect from ping; default is 'pong'
 #  user: <YOUR_USERNAME>     # if the status and ping URLs require HTTP basic auth
 #  password: <YOUR_PASSWORD> # if the status and ping URLs require HTTP basic auth
 #  http_host: <HOST>         # if your FPM pool is only accessible via a specific HTTP vhost
 #  tags:
 #    - instance:foo

Configuration Options:

  • status_url (Required) - URL for the PHP FPM status page defined in the fpm pool config file (pm.status_path)
  • ping_url (Required) - URL for the PHP FPM ping page defined in the fpm pool config file (ping.path)
  • use_fastcgi (Optional) - Communicate directly with PHP-FPM using FastCGI
  • ping_reply (Required) - Reply from the ping_url. Unless you define a reply, it is pong
  • user (Optional) - Used if you have set basic authentication on the status and ping pages
  • password (Optional) - Used if you have set basic authentication on the status and ping pages
  • http_host (Optional) - If your FPM pool is only accessible via a specific HTTP vhost, specify it here

Restart the Agent to start sending PHP-FPM metrics to Datadog.

Multiple pools

It is also possible to monitor multiple PHP-FPM pools using the same proxy server, a common scenario when running on Kubernetes.

To do so, you can modify your server’s routes to point to different PHP-FPM instances. Here is an example Nginx configuration:

server {
    ...

    location ~ ^/(status1|ping1)$ {
        access_log off;
        fastcgi_pass instance1_ip:instance1_port;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~ ^/(status2|ping2)$ {
        access_log off;
        fastcgi_pass instance2_ip:instance2_port;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

If you find this approach too tedious at scale, setting use_fastcgi to true instructs the check to bypass any proxy servers and communicate directly with PHP-FPM using FastCGI. The default port is 9000 for when omitted from status_url or ping_url.

Validation

Run the Agent’s status subcommand and look for php_fpm under the Checks section.

Data Collected

Metrics

php_fpm.listen_queue.size
(gauge)
Size of the socket queue of pending connections
php_fpm.processes.active
(gauge)
Total number of active processes
shown as process
php_fpm.processes.idle
(gauge)
Total number of idle processes
shown as process
php_fpm.processes.total
(gauge)
Total number of processes
shown as process
php_fpm.requests.accepted
(count)
Total number of accepted requests
shown as request
php_fpm.processes.max_reached
(count)
The number of times the process limit has been reached (when pm tries to start more children)
shown as process
php_fpm.requests.slow
(count)
Total number of slow requests
shown as request

Events

The PHP-FPM check does not include any events at this time.

Service Checks

php_fpm.can_ping:

Returns CRITICAL if the Agent cannot ping PHP-FPM at the configured ping_url, otherwise OK.

Troubleshooting

Need help? Contact Datadog Support.


Mistake in the docs? Feel free to contribute!