Install and configure a metrics database

API Gateway stores and maintains monitoring and transaction data in a JDBC-compliant database, which can be read by API Gateway Analytics, API Manager, and third-party monitoring tools.

This topic describes how to create and configure a database for monitoring in API Gateway Analytics

.

Prerequisites

The prerequisites for setting up the database are as follows:

Install a third-party 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 the System requirements in the API Gateway Installation Guide. For details on how to install your chosen third-party JDBC database, see your database product documentation.

Note   You must ensure that you have the correct credentials to execute the setup scripts and to access the database for operations on the tables created by the scripts.

Install API Gateway Analytics

You must install API Gateway Analytics to use it to view the monitoring data in the metrics database. For more details, see the API Gateway Installation Guide..

Add third-party JDBC driver files

You must add the JDBC driver files for your chosen third-party database to your API Gateway and Policy Studio 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 .so files to the 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 , 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 third-party database

API Gateway Analytics reads message metrics from a third-party JDBC 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 third-party 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 metrics 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.

Configure the database connection

When you have created the metrics database, you must update your API Gateway Analytics configuration with the database details using the configureserver script. For more details, see Configure API Gateway Analytics.

Set up the database tables

When you have created the metrics database and configured the database connection, the next step is to set up the database tables. For API Gateway Analytics monitoring run the dbsetup command from the following API Gateway directory:

INSTALL_DIR/analytics/posix/bin

The following example command shows setting up new database tables:

dbsetup
New database
Schema successfully upgraded to:002-leaf
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.

Specify options to dbsetup

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 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/analytics/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