Full-stack PHP monitoring

Starting with OneAgent version 1.155, you can monitor PHP on your Windows (IIS/Apache) environments—full-stack monitoring is now available on Windows for Apache mod_php applications and PHP CGI.

Enabling PHP monitoring

To enable PHP monitoring in Dynatrace

  1. Go to Settings > Monitoring > Monitored technologies and open PHP for editing.

  2. Enable the settings you need for your monitoring:

    Setting Description
    Monitor PHP on every host This switch enables PHP monitoring on all hosts. To monitor a subset of your hosts, turn this switch off and then enable PHP monitoring on selected hosts.
    Enable FastCGI PHP processes launched by Apache HTTP Server on every host Requirements:
    • PHP monitoring enabled
    • OneAgent version 1.179+
    This setting is permanently enabled starting with OneAgent version 1.191.
    Monitor PHP NG on every host Requirements:
    • PHP monitoring enabled
    • OneAgent version 1.179+
    This setting is permanently enabled starting with OneAgent version 1.191.
    Monitor PHP 7.4 on every host Requirements:
    • PHP NG monitoring enabled (see above)
    • OneAgent version 1.179+

Running PHP on a web server

The most common ways to run PHP on a web server are:

  • mod_PHP—The default on vanilla Apache HTTP servers. PHP is run as an Apache module, meaning that a PHP request is run under the Apache process. This makes PHP perform well, but flexibility is limited by the Apache configuration, permissions, restrictions, etc.
  • PHP_FPM—FastCGI Process Manager (FPM) uses pool management to optimize performance. Every pool acts as a standalone PHP instance, enabling you to create an independent configuration per pool, which provides granular control and greater flexibility. This is the fastest-performing method to run PHP.

Monitoring PHP-CLI

Early Adopter

PHP-CLI monitoring enables deep monitoring for your PHP-CLI applications. This provides you with database visibility, threading support, outgoing calls monitoring, and more. Thanks to this, you are able to:

  • Analyze the performance of your PHP-CLI application
  • Easily locate bottlenecks in your code
  • See why communication with the database takes as long as it does
  • Find out whether the application manages memory properly

Full code-level visibility into your PHP-CLI application

With PHP-CLI monitoring, you get:

  • Thread-safe and non-thread-safe driven PHP-CLI support for all Dynatrace-supported PHP versions
  • All existing OneAgent PHP features and CLI-only features:
    • pthreads support for PHP-CLI thread-safe
    • Method hotspots using ambient sampling
    • Request attributes support
    • Deep monitoring (after enabling custom service detection)

Requirements for PHP-CLI monitoring

  • OneAgent version 1.181+ installed on all monitored hosts
  • PHP NG monitoring enabled
    To check or change this setting, go to Settings > Monitoring > Monitored technologies and open PHP for editing.

Limitations of PHP-CLI monitoring

  • Injection of OneAgent causes slight overhead on process startup. It should not be enabled for short-living processes.
  • Forking inside a php-cli process is not supported. In this scenario, agent becomes inactive.
  • Instrumentation of php-cli processes with code specified as a command-line argument is not supported.
  • Instrumentation of pthreads is supported from PHP 7.2 to PHP 7.3. Earlier PHP releases are not fully thread-safe and should not be used with pthreads.

Getting started with PHP-CLI monitoring

To enable deep monitoring of your PHP-CLI applications

  1. Go to Settings > Processes and containers > Process group monitoring.

  2. Expand Process monitoring rules.

  3. Click Add a new rule to start defining a process monitoring rule for PHP-CLI.
    You can build a rule based on conditions such as:

    • EXE name
    • EXE path
    • PHP script
    • PHP working directory

    To learn more about process monitoring rules, see:

  4. Add more rules as needed.

  5. Restart your PHP application.

Making PHP-CLI monitoring work for you