APIM 1.10.x is default support for fetch data from DAS REST API. If you still want to configure APIM and DAS without RDBMS, please refer blog Publishing APIM Runtime Statistics to DAS.
APIM 1.10.x has two clients for fetching Summarized data. One is REST Client which fetch data directly from the DAS. The second one is RDBMS client which fetches data from RDBMS. By default, APIM is configured to REST client. To use with RDBMS Client you have to select the Client from <APIM_HOME>/repository/conf/api-manager.xml. you can configure it to Configure WSO2 API Manager section
Follow are the prerequisites and link to download them.
If APIM and DAS run on the same machine, increase the default service port of DAS by setting offset value in <DAS_HOME>/repository/conf/carbon.xml
<Offset>1</Offset>Define the Datasource declaration according to your RDBMS in <DAS_HOME>/repository/conf/datasources/master-datasources.xml. This DB is used to push the summarized data, after analyzing is done by DAS. Later APIM use this DB to fetch the summary data and display on APIM dashboard. Here we used the MySQL databases as an example. But you can configure it with H2, Oracle etc. Note that you should use the WSO2AM_STATS_DB as the datasoure name always.
<datasource> <name>WSO2AM_STATS_DB</name> <description>The datasource used for setting statistics to API Manager</description> <jndiConfig> <name>jdbc/WSO2AM_STATS_DB</name> </jndiConfig> <definition type="RDBMS"> <configuration> <url>jdbc:mysql://localhost:3306/TestStatsDB</url> <username>db_username</username> <password>db_password</password> <driverClassName>com.mysql.jdbc.Driver</driverClassName> <maxActive>50</maxActive> <maxWait>60000</maxWait> <testOnBorrow>true</testOnBorrow> <validationQuery>SELECT 1</validationQuery> <validationInterval>30000</validationInterval> </configuration> </definition> </datasource>
If you are used MySQL as the database, download and paste MySQL driver from here to <DAS_HOME>/repository/components/lib.
Like earliar, APIM stat publishing and analyzing using BAM, DAS does not create the table structure in the database automatically and have to do it manually. Thus find the correct schema declaration script under <APIM_HOME>/dbscript/stat/sql folder and import it to the above database.
ex: use the mysql.sql to create schema in the above DB
<!-- For APIM implemented Statistic client for DAS REST API -->
<!--StatisticClientProvider>org.wso2.carbon.apimgt.usage.client.impl.APIUsageStatisticsRestClientImpl</StatisticClientProvider-->
<!-- For APIM implemented Statistic client for RDBMS -->
<StatisticClientProvider>org.wso2.carbon.apimgt.usage.client.impl.APIUsageStatisticsRdbmsClientImpl</StatisticClientProvider>
Note that: If you are use the MySQL copy and paste the MySQL driver library to <AM_HOME>/repository/components/lib
DAS configuration overview
Deploy Sample Wheather API
Sample Wheather API
Invoke the API
WeatherAPI usage
Data purge is one option to remove historical data in DAS. Since DAS does not allow to delete the DAS table data or Table deletion this option is very important. With data purging you can achieve high performance on data analyzing without removing analyzed summary data.
Here we purge data only on stream data fired by APIM. Those data are contained in the following tables.
ORG_WSO2_APIMGT_STATISTICS_DESTINATION ORG_WSO2_APIMGT_STATISTICS_FAULT ORG_WSO2_APIMGT_STATISTICS_REQUEST ORG_WSO2_APIMGT_STATISTICS_RESPONSE ORG_WSO2_APIMGT_STATISTICS_WORKFLOW ORG_WSO2_APIMGT_STATISTICS_THROTTLE
Make sure not to purge data other than the above table. it will result in vanishing your summarized historical data.
There is two ways to purge data in DAS.
Data Purge Dialog box
Note that this will affect all the tenants
<analytics-data-purging> <!-- Below entry will indicate purging is enable or not. If user wants to enable data purging for cluster then this property need to be enable in all nodes --> <purging-enable>true</purging-enable> <cron-expression>0 0 12 * * ?</cron-expression> <!-- Tables that need include to purging. Use regex expression to specify the table name that need include to purging.--> <purge-include-table-patterns> <table>.*</table> <!--<table>.*jmx.*</table>--> </purge-include-table-patterns> <!-- All records that insert before the specified retention time will be eligible to purge --> <data-retention-days>365</data-retention-days> </analytics-data-purging>
Add Comment
Comments (0)