Statistics PHP query examples for the Wowza Streaming Engine REST API

Wowza Streaming Engine media server software includes a REST Application Programming Interface (API) that you can use to configure, manage, and monitor the media server through HTTP requests. This article describes how to get statistics related to live or on-demand (VOD) applications, live streams, and the Wowza Streaming Engine media server by using PHP to query the Wowza Streaming Engine REST service.

Notes:

Contents


Get general statistics
Get incoming stream statistics
Get historical application statistics
Get historical server statistics
For developers

Get general statistics


The following request returns application-related statistics such as total connections, bandwidth, and connection counts by protocol. This is similar to the statistics available on an application's Monitoring page in Wowza Streaming Engine Manager.
// reference statistics object
$sf = new Com\Wowza\Statistics();

// get stats per application
$wowzaApplication = new Com\Wowza\Application("vod");
$response = $sf->getApplicationStatistics($wowzaApplication);
The response includes:
{"serverName":"_defaultServer_","uptime":0,"bytesIn":0,"bytesOut":0,"bytesInRate":0,"bytesOutRate":0,"totalConnections":0,"connectionCount":{"CUPERTINO":0,"RTP":0,"MPEGDASH":0,"SMOOTH":0,"DVRCHUNKS":0,"WEBM":0,"RTMP":0,"SANJOSE":0}}

Get incoming stream statistics


The following example requests statistics for a specific application:
$sf = new Com\Wowza\Statistics();

// get stats per application
$wowzaApplication = new Com\Wowza\Application("vod");

// get incoming stream stats for given application
$response = $sf->getIncomingApplicationStatistics($wowzaApplication,"sample.mp4");
An example result:
{"serverName":"_defaultServer_","uptime":0,"bytesIn":0,"bytesOut":0,"bytesInRate":0,"bytesOutRate":0,"totalConnections":0,"connectionCount":{"CUPERTINO":0,"RTP":0,"MPEGDASH":0,"SMOOTH":0,"RTMP":0,"SANJOSE":0},"applicationInstance":"_definst_","name":"sample.mp4"}

Get historical application statistics


The following example requests related statistics over time for a specific application:
$sf = new Com\Wowza\Statistics();

// get stats per application
$wowzaApplication = new Com\Wowza\Application("vod");

// get stats historical for given application
$response = $sf->getApplicationStatisticsHistory($wowzaApplication);
An example result:
{"serverName":"_defaultServer_","entries":{"min":[{"dateTime":"2016-09-13T17:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-13T18:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-13T19:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-13T20:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-13T21:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-13T22:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-13T23:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T00:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T01:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T02:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T03:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T04:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T05:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T06:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T07:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T08:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T09:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T10:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T11:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T12:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T13:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T14:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T15:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T16:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T17:00:00","data":[0,0,0,0,0,0,0,0,0,0]}],"max":[{"dateTime":"2016-09-13T17:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-13T18:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-13T19:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-13T20:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-13T21:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-13T22:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-13T23:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T00:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T01:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T02:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T03:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T04:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T05:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T06:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T07:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T08:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T09:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T10:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T11:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T12:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T13:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T14:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T15:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T16:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T17:00:00","data":[0,0,0,0,0,0,0,0,0,0]}],"actual":[],"average":[{"dateTime":"2016-09-13T17:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-13T18:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-13T19:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-13T20:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-13T21:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-13T22:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-13T23:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T00:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T01:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T02:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T03:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T04:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T05:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T06:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T07:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T08:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T09:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T10:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T11:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T12:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T13:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T14:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T15:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T16:00:00","data":[0,0,0,0,0,0,0,0,0,0]},{"dateTime":"2016-09-14T17:00:00","data":[0,0,0,0,0,0,0,0,0,0]}]}}

Get historical server statistics


The following example requests historic statistics at the server level:
$sf = new Com\Wowza\Statistics();

// get stats per application
$wowzaApplication = new Com\Wowza\Application("vod");

// get total server stats
$server = new Com\Wowza\Server();
$response = $sf->getServerStatistics($server);
This command returns the maximum, minimum, and average data arrays in JSON syntax, which looks similar to the following:
{"serverName":"_defaultServer_","entries":{"min":[{"dateTime":"2016-09-13T17:00:00","data":[0,0,0,15]},{"dateTime":"2016-09-13T18:00:00","data":[0,0,0,15]},{"dateTime":"2016-09-13T19:00:00","data":[0,0,0,16]},{"dateTime":"2016-09-13T20:00:00","data":[0,0,0,15]},{"dateTime":"2016-09-13T21:00:00","data":[0,0,0,15]},{"dateTime":"2016-09-13T22:00:00","data":[0,0,0,16]},{"dateTime":"2016-09-13T23:00:00","data":[0,0,0,15]},{"dateTime":"2016-09-14T00:00:00","data":[0,0,0,15]},{"dateTime":"2016-09-14T01:00:00","data":[0,0,0,16]},{"dateTime":"2016-09-14T02:00:00","data":[0,0,0,16]},{"dateTime":"2016-09-14T03:00:00","data":[0,0,0,16]},{"dateTime":"2016-09-14T04:00:00","data":[0,0,0,16]},{"dateTime":"2016-09-14T05:00:00","data":[0,0,0,16]},{"dateTime":"2016-09-14T06:00:00","data":[0,0,0,16]},{"dateTime":"2016-09-14T07:00:00","data":[0,0,0,16]},{"dateTime":"2016-09-14T08:00:00","data":[0,0,0,16]},{"dateTime":"2016-09-14T09:00:00","data":[0,0,0,16]},{"dateTime":"2016-09-14T10:00:00","data":[0,0,0,16]},{"dateTime":"2016-09-14T11:00:00","data":[0,0,0,16]},{"dateTime":"2016-09-14T12:00:00","data":[0,0,0,16]},{"dateTime":"2016-09-14T13:00:00","data":[0,0,0,16]},{"dateTime":"2016-09-14T14:00:00","data":[0,0,0,16]},{"dateTime":"2016-09-14T15:00:00","data":[0,0,0,16]},{"dateTime":"2016-09-14T16:00:00","data":[0,0,0,16]},{"dateTime":"2016-09-14T17:00:00","data":[0,0,0,16]}],"max":[{"dateTime":"2016-09-13T17:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-13T18:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-13T19:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-13T20:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-13T21:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-13T22:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-13T23:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-14T00:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-14T01:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-14T02:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-14T03:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-14T04:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-14T05:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-14T06:00:00","data":[0,0,0,119]},{"dateTime":"2016-09-14T07:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-14T08:00:00","data":[0,0,0,119]},{"dateTime":"2016-09-14T09:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-14T10:00:00","data":[0,0,0,119]},{"dateTime":"2016-09-14T11:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-14T12:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-14T13:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-14T14:00:00","data":[0,0,0,119]},{"dateTime":"2016-09-14T15:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-14T16:00:00","data":[0,0,0,118]},{"dateTime":"2016-09-14T17:00:00","data":[0,0,0,118]}],"actual":[],"average":[{"dateTime":"2016-09-13T17:00:00","data":[0,0,0,66]},{"dateTime":"2016-09-13T18:00:00","data":[0,0,0,66]},{"dateTime":"2016-09-13T19:00:00","data":[0,0,0,66]},{"dateTime":"2016-09-13T20:00:00","data":[0,0,0,65]},{"dateTime":"2016-09-13T21:00:00","data":[0,0,0,66]},{"dateTime":"2016-09-13T22:00:00","data":[0,0,0,66]},{"dateTime":"2016-09-13T23:00:00","data":[0,0,0,67]},{"dateTime":"2016-09-14T00:00:00","data":[0,0,0,66]},{"dateTime":"2016-09-14T01:00:00","data":[0,0,0,67]},{"dateTime":"2016-09-14T02:00:00","data":[0,0,0,66]},{"dateTime":"2016-09-14T03:00:00","data":[0,0,0,67]},{"dateTime":"2016-09-14T04:00:00","data":[0,0,0,66]},{"dateTime":"2016-09-14T05:00:00","data":[0,0,0,65]},{"dateTime":"2016-09-14T06:00:00","data":[0,0,0,67]},{"dateTime":"2016-09-14T07:00:00","data":[0,0,0,65]},{"dateTime":"2016-09-14T08:00:00","data":[0,0,0,66]},{"dateTime":"2016-09-14T09:00:00","data":[0,0,0,67]},{"dateTime":"2016-09-14T10:00:00","data":[0,0,0,66]},{"dateTime":"2016-09-14T11:00:00","data":[0,0,0,66]},{"dateTime":"2016-09-14T12:00:00","data":[0,0,0,67]},{"dateTime":"2016-09-14T13:00:00","data":[0,0,0,66]},{"dateTime":"2016-09-14T14:00:00","data":[0,0,0,66]},{"dateTime":"2016-09-14T15:00:00","data":[0,0,0,66]},{"dateTime":"2016-09-14T16:00:00","data":[0,0,0,66]},{"dateTime":"2016-09-14T17:00:00","data":[0,0,0,66]}]}}

For developers


Source code is available on GitHub.

Wowza Media Systems™ provides developers with a platform to create streaming applications and solutions. See Wowza Developer Tools to learn more about our APIs and SDK.