Configure the metrics database

API Gateway stores and maintains the monitoring and transaction data read by API Gateway Analytics and API Manager in a JDBC-compliant database. This topic describes how to create and configure a database for use with API Gateway Analytics or API Manager monitoring. It describes the prerequisites and shows an example of creating a database. It also shows how to setup the database tables or upgrade them from a previous version.

Note   API Gateway Analytics is deprecated and will be removed in a future release.

Prerequisites

The prerequisites for setting up the database are as follows:

Install API Gateway Analytics or API Manager

You must install API Gateway Analytics or API Manager. For more details, see:

Install a JDBC database

You must install a JDBC-compliant database to store the monitoring and transaction data. Axway provides setup scripts for the following databases:

  • MySQL or MariaDB
  • Microsoft SQL Server
  • Oracle
  • IBM DB2

For details on supported database versions, see System requirements. For details on how to install your chosen JDBC database, see your database product documentation.

Add third-party JDBC driver files

You must add the JDBC driver files for your chosen third-party database to your API Gateway, Policy Studio, and API Gateway Analytics installations as appropriate.

Add JDBC drivers to API Gateway

To add the third-party JDBC driver files for your database to API Gateway, perform the following steps:

  1. Add the binary files for your database driver as follows:
    • Add .jar files to INSTALL_DIR/apigateway/ext/lib
    • Add .dll files to INSTALL_DIR\apigateway\Win32\lib
    • Add .so files to INSTALL_DIR/apigateway/platform/lib
  2. Restart API Gateway.

Add JDBC drivers to Policy Studio

To add third-party binaries to Policy Studio, perform the following steps:

  1. Select Window > Preferences > Runtime Dependencies from the Policy Studio main menu.
  2. Click Add to select a JAR file to add to the list of dependencies.
  3. Click Apply when finished. A copy of the JAR file is added to the plugins directory in your Policy Studio installation.
  4. Click OK.
  5. Restart Policy Studio using the policystudio -clean command.

Add JDBC drivers to API Gateway Analytics

To add the third-party JDBC driver files for your database to API Gateway Analytics (if installed), perform the following steps:

  1. Add the binary files for your database driver as follows:
    • Add .jar files to the INSTALL_DIR/analytics/ext/lib directory
    • Add .dll files to the INSTALL_DIR\analytics\Win32\lib directory
    • Add .so files to the INSTALL_DIR/analytics/platform/lib directory
  2. Restart API Gateway Analytics.

Create the database

API Gateway Analytics and API Manager monitoring read message metrics from a database and display this information in a visual format to administrators. This is the same database in which API Gateway stores its message metrics and audit trail data. You must first create this database using the third-party database of your choice:

  • MySQL or MariaDB
  • Microsoft SQL Server
  • Oracle
  • IBM DB2

For details on how to do this, see the product documentation for your chosen database. The following example shows creating a MySQL or MariaDB database:

mysql> CREATE DATABASE reports;
Query OK, 1 row affected (0.00 sec)

In this example, the database is named reports, but you can use any appropriate name.

Set transaction isolation to READ COMMITTED

For all supported databases, to ensure atomicity and consistency, you must ensure that the transaction isolation level is set to READ COMMITTED. This setting is recommended whether you are installing for the first time or upgrading.

Note   Read-committed transaction isolation mode is the default mode for Oracle, Microsoft SQL Server, and IBM DB2, but not for MySQL or MariaDB. If you are using MySQL or MariaDB, you must change to read-committed transaction isolation mode after installation and before you start the server for the first time.

For more details, see the product documentation for your chosen third-party database.

Set up the database tables

When you have created the database, the next steps depend on whether you are using API Gateway Analytics or API Manager.

API Gateway Analytics

After creating the database, the next step is to configure the database connection. Configure your API Gateway Analytics database shows all of the steps in the correct order.

After configuring the database connection, you can create the database tables by running the dbsetup command without any options from the following API Gateway Analytics directory:

Windows INSTALL_DIR\analytics\Win32\bin
UNIX/Linux INSTALL_DIR/analytics/posix/bin
Note   You do not need to run dbsetup again for API Manager monitoring if it has already been run for API Gateway Analytics.

API Manager

For API Manager monitoring, you can run the dbsetup command from the following API Gateway directory:

Windows INSTALL_DIR\apigateway\Win32\bin
UNIX/Linux INSTALL_DIR/apigateway/posix/bin

For more details on API Manager monitoring, see the API Manager User Guide.

Example command

The following example applies to both API Gateway Analytics and API Manager monitoring, and shows setting up new database tables:

dbsetup
New database
Schema successfully upgraded to:002-leaf

Specify options to dbsetup

Note   When you specify command-line arguments to dbsetup, the script does not run interactively. You should run dbsetup without any options to create the database tables.

You can specify the following options to the dbsetup command:

Option Description
-h, --help Displays help message and exits.
-p PASSPHRASE, --passphrase=PASSPHRASE Specifies the configuration passphrase (blank for zero length).
--dbname=DBNAME Specifies the database name (mutually exclusive with --dburl,--dbuser, and --dbpass).
--dburl=DBURL Specifies the database URL.
--dbuser=DBUSER Specifies the database user.
--dbpass=DBPASS

Specifies the database password. You must enclose passwords that contain special characters in single quotation marks. For example:

./dbsetup --dburl=mysql://127.0.0.1:3306/reports --dbuser=root --dbpass='AcmeCorp!23'

--reinstall Forces a reinstall of the database, dropping all data.
--stop=STOP Stops the database upgrade after the named upgrade.

dbsetup examples

The following are some examples of using dbsetup command options.

Connect to a named database

You can use the --dbname option to connect to a named database connection configured under the External Connections node in the Policy Studio tree. For example:

dbsetup --dbname=Oracle
Current schema version:001-initial
Latest schema version:002-leaf
Schema successfully upgraded to:002-leaf

Connect to a database URL

You can use the --dburl option to manually connect to a database instance directly using a URL. For example:

dbsetup --dburl=jdbc:mysql://localhost/reports --dbuser=root --dbpass=admin
Current schema version:001-initial
Latest schema version:002-leaf
Schema successfully upgraded to:002-leaf

Install a database

You can also use the --dburl option to set up a newly created database instance where none already exists. For example:

dbsetup --dburl=jdbc:mysql://localhost/reports --dbuser=root --dbpass=admin
New database
Schema successfully upgraded to:002-leaf

Reinstall a database

You can use the --reinstall option to wipe and reinstall a database. For example:

dbsetup --dburl=jdbc:mysql://localhost/reports --dbuser=root --dbpass=admin --reinstall
Re-installing database...
Schema successfully upgraded to:002-leaf

SQL database schema scripts

As an alternative to using the dbsetup command, API Gateway Analytics also provides separate SQL schema scripts to set up the database tables for each of the supported databases. However, these scripts set up new tables only, and do not perform any upgrades of existing tables. These scripts are provided in the INSTALL_DIR/system/conf/sql directory in the following sub-directories:

  • /mysql
  • /mssql
  • /oracle
  • /db2
Note   The scripts in the /mysql folder apply to both MySQL and MariaDB.

You can run the SQL commands in the analytics.sql file in the appropriate directory for your database. The following example shows creating the tables for a MySQL database:

mysql> \. INSTALL_DIR/analytics/system/conf/sql/mysql/analytics.sql
Query OK, 0 rows affected, 1 warning (0.00 sec)
Query OK, 0 rows affected, 1 warning (0.00 sec)
...

Related Links