Logging Player Counts to Database

Measure module gives you a very simple but flexible solution to implement your own logging. As all tools on this site, it has a bit techie approach, so you don’t get any charts and GUI’s, but I beleive it gives you the most flexible way logging: you can define a database connection and use your custom SQL queries to insert collect data exactly how you need that. This allows you to integrate with your existing system and also to use collected data in your own charting solution later.

Install the Measure module

The Measure module is a single jar file that you can download from the toolbox. Copy the measure-xxx.jar file under the lib directory of your Wowza installation (e.g. /usr/local/share/WowzaStreamingEngine/lib) where you can find all the other jar files. Putting this file there will automatically include in on the classpath where Wowza can load the module if any application refers to it.

If you copied the jar file to the right place and added it to your Application.xml (comes later), you should see this line in your logs:

Starting Measure 2017.02.12
Using database url ..., user ....

If you did not put it to the right place, you should see this in the logs:

Module class not found or could not be loaded. Check [install-dir]/conf/live/Application.xml to be sure all Modules/Module/Class paths are correct: name:Measure class:com.streamtoolbox.Measure

Add required libraries

Measure needs the JDBC driver of the database that you are using to establish the connection. Copy the JDBC driver jar file under the lib directory of your Wowza installation.

Set up the tables in your database

Please create the tables in your schema to store collected data. The following two tables are just an example that you can start with:

CREATE TABLE `wtb_applog` (
  `APPLICATION` varchar(64) NOT NULL,
  `TOTAL` int(11) NOT NULL,

CREATE TABLE `wtb_streamlog` (
  `STREAM` varchar(64) NOT NULL,
  `TOTAL` int(11) NOT NULL,
  `FLASH` int(11) NOT NULL,

Configure Measure in your Wowza application

In Wowza terminology, an “application” is a unit of configuration that can serve multiple streams. You create a new application by creating an empty folder with the desired application name under Wowza’s application directory, such as myapp. Create the same named directory under conf and copy the default conf/Applicaton.xml there, or if you already have your application configured, then just add the following module definition under <Modules>

    <Description>Measure allows you to capture connection counts periodically</Description>

The above snippet enables the module on your application. You also need to specify the settings for Wrench as follows:


  <Property><Name>measure.application.level.sql</Name><Value>insert into wtb_applog (application, total) values (:application, :total)</Value></Property>
  <Property><Name>measure.stream.level.sql</Name><Value>insert into wtb_streamlog (stream, total, flash, cupertino) values (:stream, :total, :flash, :cupertino)</Value></Property>

(Note: if you also use Wrench, you can clone all Wrench DB settings by setting measure.db.settings to wrench)

The above configuration instructs Measure to log connection counts every 30 seconds using the configured database connection and the two provided queries.

measure.application.level.sql allows you to capture data on application level. That means that data is aggregated for all the streams that are flowing in that particular application. In the query you can use parameters such as the name of the application (:application), the number of players per streaming technology, etc.

measure.stream.level.sql allows you to do the same on stream level, which means that this query is executed in a loop for each stream in that application. The parameters like :total in this case all refer to that particular stream only.

One nice thing here is that Wowza Measure allows you to capture player information per streaming technology by using the :flash, :cupertino, :sanjose, etc. parameters. This allows you to get fine-grained information about your stream usage.

Now start your Wowza Streaming Engine® and publish your stream. In the logs you should see something like:

1 2014-04-26 19:55:19 myapp 0
2 2014-04-26 19:55:49 myapp 1
3 2014-04-26 19:56:19 myapp 1

If you want charts, you can use Microsoft Excel with an ODBC data source to generate diagrams for you.

That’s it. You have successfully set up a very simple player count logging for your Wowza application. If you are interested in all the features of Measure, take a look at the reference docs.