我正在尝试集成BAM服务器(2.4.0)和API管理(1.6)获取错误:
TID:[0] [AM] [2014-04-11 08:45:17,838]错误 {org.wso2.carbon.apimgt.hostobjects.APIProviderHostObject} - 错误 同时为ProviderAPIUsage调用APIUsageStatisticsClient {} org.wso2.carbon.apimgt.hostobjects.APIProviderHostObject org.wso2.carbon.apimgt.usage.client.exception.APIMgtUsageQueryServiceClientException: BAM数据源尚未初始化。确保数据源 已在APIUsageTracker配置中正确配置。在 org.wso2.carbon.apimgt.usage.client.APIUsageStatisticsClient.queryFirstAccess(APIUsageStatisticsClient.java:1693) 在 org.wso2.carbon.apimgt.usage.client.APIUsageStatisticsClient.getFirstAccessTime(APIUsageStatisticsClient.java:1675) 在 org.wso2.carbon.apimgt.hostobjects.APIProviderHostObject.jsFunction_getFirstAccessTime(APIProviderHostObject.java:2911) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
我的数据源定义为
<datasource>
<name>WSO2AM_STATS_DB</name>
<description>The datasource used for getting statistics to API Manager</description>
<jndiConfig>
<name>jdbc/WSO2AM_STATS_DB</name>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:h2:C:/esb/wso2bam-2.4.0/repository/database/APIMGTSTATS_DB;AUTO_SERVER=TRUE</url>
<username>wso2carbon</username>
<password>wso2carbon</password>
<driverClassName>org.h2.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
</configuration>
</definition>
</datasource>
另外,我注意到BAM服务器之后抛出了以下错误
错误{org.wso2.carbon.hadoop.hive.jdbc.storage.db.DBOperation} - 无法将数据写入数据库org.h2.jdbc.JdbcSQLException:NULL 不允许列&#34;消费者&#34 ;; SQL语句:INSERT INTO API_REQUEST_SUMMARY (版本,consumerkey,max_request_time,API_VERSION,时间,主机名,背景,一天,一年,一个月,total_request_count,用户ID,APIP ublisher,api)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)[90006-140]
我已按照说明操作了 https://docs.wso2.org/display/AM160/Publishing+API+Runtime+Statistics
非常感谢任何帮助
答案 0 :(得分:1)
由于将consumerKey作为null添加到数据库中,因此存在此问题。这已在API管理器2.0.0中修复。您可以找到此问题的相关JIRA ticket APIMANAGER-2032。
要解决此问题,您需要修改可在BAM实例中找到的API管理器统计分析器配置单元脚本。打开它并编辑以下插入查询。然后AM将空字符串添加为'anonymous',这是期望值(COALESCE(consumerKey,''))。
insert overwrite table APIRequestSummaryData select api, api_version,version, apiPublisher, COALESCE(consumerKey,''),userId,context,max(requestTime) as max_request_time,sum(request) as total_request_count,hostName, year(from_unixtime(cast(requestTime/1000 as BIGINT),'yyyy-MM-dd HH:mm:ss.SSS' )) as year, month(from_unixtime(cast(requestTime/1000 as BIGINT),'yyyy-MM-dd HH:mm:ss.SSS' )) as month,day(from_unixtime(cast(requestTime/1000 as BIGINT),'yyyy-MM-dd HH:mm:ss.SSS' )) as day,concat(substring(from_unixtime(cast(requestTime/1000 as BIGINT), 'yyyy-MM-dd HH:mm:ss'),0,16),':00') as time from APIRequestData group by api,api_version,version,apiPublisher,consumerKey,userId,context,hostName,year(from_unixtime(cast(requestTime/1000 as BIGINT),'yyyy-MM-dd HH:mm:ss.SSS' )), month(from_unixtime(cast(requestTime/1000 as BIGINT),'yyyy-MM-dd HH:mm:ss.SSS' )),day(from_unixtime(cast(requestTime/1000 as BIGINT),'yyyy-MM-dd HH:mm:ss.SSS' )),hour(from_unixtime(cast(requestTime/1000 as BIGINT),'yyyy-MM-dd HH:mm:ss.SSS' )),minute(from_unixtime(cast(requestTime/1000 as BIGINT),'yyyy-MM-dd HH:mm:ss.SSS' )),substring(from_unixtime(cast(requestTime/1000 as BIGINT), 'yyyy-MM-dd HH:mm:ss'),0,16);
同样,修改hive脚本中尝试编写insert
的所有consumerKey
个查询。所有查询的结构几乎相同,因此不难改变。