Configure Metering Service in AMP

AMP can be configured to record application and location lifecycle events to a SQL database:

  • Uses a JDBC connection. It has been tested with H2 and MYSQL, though other RDBMSs are likely to work.
  • For locations, records created and destroyed events.
  • For applications, records starting, running, stopping, stopped, destroyed and on-fire events.


Metering is enabled and configured via the file, usually located at ~/.brooklyn/

To enable metering to a database, add the following lines to your file

# MYSQL Metering DB Listener

The brooklyn.usageManager.listeners key takes a comma-delimited list of listener classes. In this case we are using the io.cloudsoft.metering.MeteringDbListener, which is used when recording events to a SQL database

The following lines are configuration options specific to the MeteringDbListener, and should be set as follows:

  • amp.metering.listener.db.jdbcDriverClass: This is the fully qualified classname of the JDBC driver to be used. Leave this empty for MariaDB, and for H2, use org.h2.Driver. Currently these are the only supported drivers available for Amp to use.
  • amp.metering.listener.db.jdbcConnectionString: This is the jdbc connection string which AMP will use to connect to the database. Note: This should point to an exising database instance, and the database must have been created in advance. The schema (tables) can be automatically generated (see db.init below), but the server and database must be created manually
  • amp.metering.listener.db.jdbcUsername: This is the username that AMP will use to connect to the database
  • amp.metering.listener.db.jdbcPassword: This is the password that AMP will use to connect to the database
  • amp.metering.listener.db.init: If true, AMP will attempt to initialize the database tables. This must be done the first time that the database is used. The operation is idempotent - if the tables exist, the operation is a no-op (even if the existing schema is different from that expected).

A sample MYSQL script to create a database, username, and password is as follows

USE foo;
CREATE USER 'myuser' identified by 'L3tM3!n';
GRANT USAGE ON *.* TO 'myuser'@'%' IDENTIFIED BY 'L3tM3!n';
GRANT USAGE ON *.* TO 'myuser'@'localhost' IDENTIFIED BY 'L3tM3!n';
GRANT ALL PRIVILEGES ON foo.* TO 'myuser'@'%';