PHP
How to send metrics using PHP
Interesting PHP Metrics Libraries
PHP StatsD https://github.com/domnikl/statsd-php - A PHP StatsD client available in Composer https://github.com/seejohnrun/php-statsd - A simple PHP StatsD client
Sending a metric via TCP
<?
$conn = fsockopen("carbon.hostedgraphite.com", 2003);
fwrite($conn, "YOUR-API-KEY.foo.php-tcp 1.2\n");
fclose($conn);
?>
Sending a metric via UDP
<?
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$message = "YOUR-API-KEY.foo.php-udp 1.2\n";
socket_sendto($sock, $message, strlen($message), 0, "carbon.hostedgraphite.com", 2003);
?>
Sending a metric via UDP on Heroku
<?
$fp = fsockopen('udp://carbon.hostedgraphite.com', 2003);
fwrite($fp, "YOUR-API-KEY.foo.php-heroku 1.2\n");
fclose($fp);
?>
Your API key can be found on your account home page.
Last updated
Was this helpful?