我已安装API管理器和BAM产品来查看API管理器统计信息。查看BAM表,我可以看到为APIRequestData和APIResponseData填充的数据,但没有填充任何摘要数据表。
am_stats_analyzer_xxx脚本计划运行。我已经尝试手动运行插入脚本。
当我手动运行以下查询时,它也没有填充APIRequestSummaryData表。但是,当我只执行查询的“选择部分”时,它确实调出了结果集。
insert overwrite table APIRequestSummaryData select api, api_version,version, apiPublisher, 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);
使用
创建APIRequestSummaryData表CREATE EXTERNAL TABLE IF NOT EXISTS APIRequestSummaryData (api STRING, api_version STRING, version STRING, apiPublisher STRING,
consumerKey STRING,userId STRING,context STRING, max_request_time BIGINT,
total_request_count INT, hostName STRING,year SMALLINT,month SMALLINT,day SMALLINT, time STRING) STORED BY
'org.wso2.carbon.hadoop.hive.jdbc.storage.JDBCStorageHandler' TBLPROPERTIES ( 'wso2.carbon.datasource.name'='WSO2AM_STATS_DB',
'hive.jdbc.update.on.duplicate' = 'true',
'hive.jdbc.primary.key.fields'='api,api_version,version,apiPublisher,consumerKey,userId,context,hostName,time',
'hive.jdbc.table.create.query' = 'CREATE TABLE API_REQUEST_SUMMARY ( api VARCHAR(100), api_version VARCHAR(100), version VARCHAR(100),
apiPublisher VARCHAR(100),consumerKey VARCHAR(100),userId VARCHAR(100), context VARCHAR(100),max_request_time BIGINT, total_request_count INT, hostName VARCHAR(100), year SMALLINT, month SMALLINT, day SMALLINT, time VARCHAR(30),PRIMARY KEY(api,api_version,apiPublisher,consumerKey,userId,context,hostName,time))' );