3

I have configured API Manager 2.0.0 & API Manager Analytics Pack to use MySQL databases.
For each server, there exists a WSO2AM_STATS_DB. I have given these differing names on my MySQL server. I have also pointed my datasources in master-datasources.xml(for APIM) & stats-datasources.xml(for Analytics) to the relevant databases.
I couldn't find any relevant schema(dbscripts) for these databases in their respective packs.

On running, the Analytics database is populated but the APIM database isn't and throws an exception. The Analytics database not only gets the schema but also the invocation details of my API. I am unable to get the stats on my dashboard though.

Previously, I (unwittingly) configured the h2-repository stats database to be the same for both servers (due to the folder structure) and was able to get all the statistics on my dashboard in the publisher.

Other configurations I have tried : On the MySQL Server, pointed it to the same database (the Analytics one with the schema) but with no results on my dashboard (after waiting for a while).

Jaden
  • 145
  • 5

1 Answers1

2

Both datasources (WSO2AM_STATS_DB) in 2 servers should be pointed to the same database. There are no database scripts for this. Tables are created automatically.

By default in both servers, Stats DB path comes like this. (note ../ part)

<url>jdbc:h2:../tmpStatDB/WSO2AM_STATS_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000;AUTO_SERVER=TRUE</url>

So if you extract both servers to the same directory as mentioned in this doc, both datasources will be pointing to the same database (inside tmpStatDB) like this.

/parent_dir
     |__wso2am-2.0.0/
     |__wso2am-analytics-2.0.0/
     |__tmpStatDB/

So, what happens here is, wso2am-analytics writes stats data to shared database, then apim reads it and shows data on its databases.

Bee
  • 12,251
  • 11
  • 46
  • 73
  • Thanks Bhathiya... Its really helpful...We achieved this using same approach. Is there any way to achieve this without using shared DB? – sachin dhus Oct 18 '16 at 07:34
  • @sachindhus There was a way to read data from a REST API. But it was removed from 2.0.0 due to performance reasons. So, currently, there is no way to do that without having a shared db. Could you please explain the reason why you can't have a shared db? – Bee Oct 18 '16 at 07:42
  • @Bhathiya Yes, the situation you've described above explains why my initial h2 configuration was working(as mentioned in my question). If I've understood you correctly, the transfer of information from the analytics server to the API manager is not through a REST API but the shared database? I've seen some configuration for DAS to receive info through REST in an XML file.. – Jaden Oct 18 '16 at 09:39
  • You can read stat data from DAS REST API. APIM 1.10.0 had a configuration to use those REST APIs to read stat data. But APIM 2.0.0 Dashboards don't use them to read stat data anymore. – Bee Oct 18 '16 at 11:04
  • I find it strange that there are no database scripts for the stats database and yet [the clustering guide](https://docs.wso2.com/display/CLUSTER44x/Clustering+API+Manager+2.0.0) has the following: `mysql> source /dbscripts/stat/sql/mysql.sql;`. Is this a bug in the documentation? Maybe a note around this would be useful. – Jonathan Williams Oct 21 '16 at 08:45
  • This also appears to be incorrect on this page: https://docs.wso2.com/display/AM1100/Publishing+API+Runtime+Statistics+Using+RDBMS – Jonathan Williams Oct 21 '16 at 09:15
  • In 1.10.0 you need to run the script, but in 2.0.0 you don't have to. I asked WSO2 docs team to remove that line from 2.0.0 docs. Thanks for reporting. – Bee Oct 21 '16 at 09:32