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
anddestroyed
events. - For applications, records
starting
,running
,stopping
,stopped
,destroyed
andon-fire
events.
Configuration
Metering is enabled and configured via the brooklyn.properties
file, usually located at ~/.brooklyn/brooklyn.properties
To enable metering to a database, add the following lines to your brooklyn.properties file
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, useorg.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 (seedb.init
below), but the server and database must be created manuallyamp.metering.listener.db.jdbcUsername
: This is the username that AMP will use to connect to the databaseamp.metering.listener.db.jdbcPassword
: This is the password that AMP will use to connect to the databaseamp.metering.listener.db.init
: Iftrue
, 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