Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The API Manager Analytics provides reports, statistics and graphs on the APIs deployed in WSO2 Open Banking API Manager. You can then configure alerts to monitor these APIs and detect unusual activity, manage locations via geo-location statistics and carry out a detailed analysis of the logs. 

...

Info

When using Oracle or MS SQL, download the database driver and include it within <WSO2_APIM_ANALYTICS_HOME>/lib directory.

  1. Create the ANALYTICS_DB database in your database server.

  2. Configure the worker profile.   

    Open the <WSO2_OB_API-M_ANALYTICS_HOME>/conf/worker/deployment.yaml file. Update the APIM_ANALYTICS_DB datasource with your database configurations.

    Code Block
    languagexml
    titledeployment.yaml
    - name: APIM_ANALYTICS_DB
    description: The Datasource used for APIM Analytics
    jndiConfig:
      name: jdbc/APIM_ANALYTICS_DB
    definition:
      type: RDBMS
      configuration:
        jdbcUrl: 'jdbc:<DB_TYPE>://<DB_HOST>:<DB_PORT>/ANALYTICS_DB?autoReconnect=true&useSSL=false'
        username: <DB_USERNAME>
        password: <DB_PASSWORD>
        driverClassName: <DB_DRIVER>
        maxPoolSize: 50
        idleTimeout: 60000
        connectionTestQuery: SELECT 1
        validationTimeout: 30000
        isAutoCommit: false
  3. Configure the dashboard profile.   

    Open the <WSO2_OB_API-M_ANALYTICS_HOME>/conf/dashboard/deployment.yaml file. Update the APIM_ANALYTICS_DB datasource with your database configurations.

    Code Block
    languagexml
    titledeployment.yaml
    - name: APIM_ANALYTICS_DB
    description: The Datasource used for APIM Analytics
    jndiConfig:
      name: jdbc/APIM_ANALYTICS_DB
    definition:
      type: RDBMS
      configuration:
        jdbcUrl: 'jdbc:<DB_TYPE>://<DB_HOST>:<DB_PORT>/ANALYTICS_DB?autoReconnect=true&useSSL=false'
        username: <DB_USERNAME>
        password: <DB_PASSWORD>
        driverClassName: <DB_DRIVER>
        maxPoolSize: 50
        idleTimeout: 60000
        connectionTestQuery: SELECT 1
        validationTimeout: 30000
        isAutoCommit: false
    Tip

    By default, the following datasource entries are configured to H2 databases. If required, you can create external databases and point these entries to them.

    Datasource NameFile
    BUSINESS_RULES_DB<WSO2_OB_API-M_ANALYTICS_HOME>/conf/dashboard/deployment.yaml
    WSO2_PERMISSIONS_DB<WSO2_OB_API-M_ANALYTICS_HOME>/conf/worker/deployment.yaml <WSO2_OB_API-M_ANALYTICS_HOME>/conf/dashboard/deployment.yaml
    Note

    The GEO_LOCATION_DATA datasource should be configured when you are using Geo-location based statistics

  4. Integrate third-party products when configuring databases.

    Note

    WSO2 SP is a OSGi-based product. Therefore, when you integrate third party products such as Oracle and MS SQL with WSO2 API-M Analytics, you need to check whether the libraries you need to add are OSGi based. If they are not, you need to convert them to OSGi bundles before adding them to the <WSO2_OB_API-M_ANALYTICS_HOME>/lib directory. 

    To convert the jar files to OSGi bundles, follow the steps below.

    1. Download the non-OSGi jar for the required third party product, and save it in a preferred directory in your machine.

    2. Go to the <API-M_ANALYTICS_HOME>/bin directory. Run the command given below, to generate the converted file in the <API-M_ANALYTICS_HOME>/lib directory.

    Code Block
    ./jartobundle.sh <PATH_TO_NON-OSGi_JAR> ../lib

Configuring

...

the Keystores

In the SSL handshake between the API Management profile Manager and the API Manager Analytics profileservers, the client /API Management profile (i.e. API Manager) needs to verify the certificate presented by the server /Analytics profile(i.e. API Manager Analytics). For this purpose, the client stores the trusted certificate of the server in the the client-truststore.jks keystore keystore.

If you use a custom keystore in API Manager and/or API Manager Analytics, import the public key certificate of the Analytics profile into the of API Manager Analytics into the client-truststore.jks file of the API Management profile file of the API Manager. To export the public key from the server , and import it into the client's truststoretrust store, follow the steps below:

Step 1: Generating a CA-signed certificate

First, you need to generate a Certificate Signing Request (CSR) for your keystore (.jks file). This CSR file can then be certified by a certification authority (CA), which is an entity that issues digital certificates. These certificates certify the ownership of a public key.

  1. Execute the following command to generate the CSR:

    Code Block
    keytool -certreq -alias certalias -file newcertreq.csr -keystore newkeystore.jks

    You are asked to give the keystore password. Once the password is given, the command outputs the new certreq.csr file to the wso2am-analytics-2.6.0/resources/security directory. This is the CSR that you must submit to a CA.

  2. You must provide this CSR file to the CA.
  3. After accepting the request, a signed certificate is provided along with a root certificate and several intermediate certificates (depending on the CA) as a bundle (.zip file).

Step 2: Importing certificates to the keystore

Follow the steps given below to import the CA-signed certificate to your keystore.

...

Before importing the CA-signed certificate to the keystore, you must add the root CA certificate and the two (related) intermediate certificates by executing the commands given below. Note that the sample certificates given above are used as examples:

Code Block
keytool -import -v -trustcacerts -alias ExternalCARoot -file AddTrustExternalCARoot.crt -keystore newkeystore.jks -storepass mypassword

keytool -import -v -trustcacerts -alias TrustCA -file COMODORSAAddTrustCA.crt -keystore newkeystore.jks -storepass mypassword

keytool -import -v -trustcacerts -alias SecureServerCA -file COMODORSADomainValidationSecureServerCA.crt -keystore newkeystore.jks -storepass mypassword 

After you add the root certificate and all other intermediate certificates, add the CA-signed SSL certificate to the keystore by executing the following command:

Code Block
keytool -import -v -alias newcert -file <test_sampleapp_org.crt> -keystore newkeystore.jks -keypass mypassword -storepass mypassword
Info
In this command, use the same alias (i.e., newcert) that you used while creating the keystore.

Now you have a Java keystore, which includes a CA-signed public key certificate that can be used for SSL in a production environment. 

Next, you may need to add the same CA-signed public key certificate to the client-truststore.jks file. This provides security, and trust for backend communication/inter-system communication of WSO2 products via SSL.

Step 3: Importing certificates to the truststore

In SSL handshake, the client needs to verify the certificate presented by the server. For this purpose, the client usually stores the certificates it trusts, in a truststore. To enable secure and trusted backend communication, all WSO2 products are shipped with a truststore named client-truststore.jks, which resides in the same directory as the default keystore (wso2am-analytics-2.6.0/resources/security).

Follow the steps given below to import the same CA-signed public key certificate (which you obtained in the previous step) into your WSO2 product's default truststore (client-truststore.jks).

  1. Get a copy of the client-truststore.jks file from the wso2am-analytics-2.6.0/resources/security directory.
  2. Export the public key from your .jks file using the following command.

    Code Block
    keytool -export -alias certalias -keystore newkeystore.jks -file <public key name>.pem
  3. Import the public key you extracted in the previous step to the client-truststore.jks file using the following command.

    Code Block
    keytool -import -alias certalias -file <public key name>.pem -keystore client-truststore.jks -storepass wso2carbon

    Note that wso2carbon is the keystore password of the default client-truststore.jks file.

    Now, you have an SSL certificate stored in a Java keystore and a public key added to the client-truststore.jks file. Note that both these files should be in the wso2am-analytics-2.6.0/resources/security directory. You can now replace the default wso2carbon.jks keystore in your product with the newly created keystore by updating the relevant configuration files in your product.

Enabling performance tuning and starting the servers

given in Adding CA-signed certificates to keystores in the Administration Guide.

Starting the servers

Note

You can enable performance tuning by adding configurations, as described

...

in Performance Tuning

...

 in the WSO2

...

Stream Processor documentation.


  1. Set the path and hostname to API-M Analytics in the wso2-obam1.3.0/repository/resources/finance/script/startup.properties file.Navigate to the wso2-obam-1.3.0/repository/resources/finance/scripts/wso2am-analytics folder, give execution permissions to the configure-am-analytics.sh file, and run it.
  2. Navigate to the wso2am-analytics-2.6.0/bin directory, and give execution permissions to the worker.sh file.
  3. Run the API-M Analytics worker.sh as follows:

    Code Block
    ./bin/worker.sh -Dsetup
  4. Navigate to the wso2am-analytics-2.6.0/bin directory, and give execution permissions to the dashboard.sh file.
  5. Run the API-M Analytics dashboard.sh as follows:

    Code Block
    ./bin/dashboard.sh -Dsetup
  6. Open the wso2-obam-1.3.0/repository/conf/api-manager.xml file to enable analytics:

    Code Block
    <Analytics>
         <Enabled>true</Enabled>
    <Analytics>
  7. Save your changes and restart the API-M server from the wso2-obam-1.3.0/bin directory.
  8. You can view analytics data as described below:
    1. Log in to the API Store using the credentials provided during signup.
    2. Click the Analytics tab.
    3. You can view API Usage, Top Users and Faulty Invocations details through the subtopics.
  9. To observe data analysis based on geographical locations, see Configuring Geolocation Based Statistics.