You can monitor your PHP applications using our PHP client library, the Linux Agent, and the Netuitive StatsD server. To get up and running, all you'll need is to install our Linux Agent and then instrument custom metrics.
- Set the statsd setting in the netuitive-agent.conf file to enabled = True.
# local statsd server [[[statsd]]] enabled = True
- 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.
- Include the client library file on any page you want to collect metrics, or you can reference the file globally.
- Instrument your application code by calling the appropriate functions. Check out the example below or the timer example included in the library repo.Example(s) What follows are examples of how to create metrics using the types compatible with our Netuitive PHP Client library:
//add a gauge in any section of your code .gauge('test.data.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 measure. //the timing function expects time in milliseconds .timing('test.data.timer', 1000, 1); //you can add or subtract from any metric with these functions .increment('test.data.counterup', 1); .decrement('test.data.counterdown', 1);
These metrics will show up under the statsd node in the Metrics page like so:
- Save your application, and restart both your application and the Linux Agent.