You can monitor your PHP applications using our PHP client library, the Linux Agent, and the Metricly StatsD server. To get up and running, all you’ll need is to install our Linux Agent and then instrument custom metrics.

For the configuration section and examples, we used our own PHP client library, but you can use any compatible PHP client library. The Metricly PHP Client library currently only has support for gauges, counters, and timers; please feel free to extend our library or use another library you’ve found online. Note that while some libraries may support varying metric types, the Metricly StatsD server only supports gauge, set, counter, timer, and histogram types. See the Metricly StatsD server doc for more info.


Before you configure metric instrumentation in your PHP application(s), you’ll need to install the Linux Agent and Metricly StatsD server first. See the instructions on this page for how to install it.
  1. Set the statsd setting in the metricly-agent.conf file to enabled = True.
    # local statsd server
    enabled = True
  2. StatsD requires a client library to push metrics, so you’ll need to install a PHP client library. We have a PHP client library that can be found in our GitHub repository. The open source community also has many PHP client libraries for StatsD that should all work with our agent.
  3. Include the client library file on any page you want to collect metrics, or you can reference the file globally.
    include 'StatsD_Client.php';
  4. Instrument your application code by calling the appropriate functions. Check out the example below or the timer example included in the library repo.

    hat follows are examples of how to create metrics using the types compatible with our Metricly PHP Client library:

    //add a gauge in any section of your code
    .gauge('', 20);
    //to add this time you must first add code to 
    calculate the start and end time.
    //typically we use epoch time.  And add code at 
    the start and end of the code you want to 
    //the timing function expects time in
    .timing('', 1000, 1);
    //you can add or subtract from any metric with 
    these functions
    .increment('', 1);
    .decrement('', 1);

    These metrics will show up under the statsd node in the Metrics page like so:

  5. Save your application, and restart both your application and the Linux Agent.


Redhat 6 and 7
CentOS 6 and 7
Amazon Linux (latest)
Ubuntu 12, 14, 15, and 16
Debian 7, 8, and 9
Linux Agent
Metricly StatsD Server
PHP Client Library