本文共 3684 字,大约阅读时间需要 12 分钟。
CREATE TABLE `sls_event` ( `time` int(11) NOT NULL DEFAULT '0', `event_type` char(32) NOT NULL DEFAULT '', `event_value` char(128) NOT NULL DEFAULT '', `value` int(11) DEFAULT NULL, PRIMARY KEY (`time`,`event_type`,`event_value`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;CREATE TABLE `sls_status` ( `time` int(11) NOT NULL DEFAULT '0', `event_type` char(32) NOT NULL DEFAULT '', `event_value` char(128) NOT NULL DEFAULT '', `value` int(11) DEFAULT NULL, PRIMARY KEY (`time`,`event_type`,`event_value`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE STREAM TABLE source_test_sls_galaxy (ip STRING, status INT, request STRING,refer STRING,user_agent STRING ) WITH ( type='loghub', endpoint='http://project_region.log.aliyuncs.com', accessId='!@#$',accessKey='@#$%', projectName='#$$%%', logstore='!@#$%' );
CREATE RESULT TABLE sls_event (time INT,event_type STRING,event_value STRING,value INT) WITH (type='mysql',url='jdbc:mysql://@#$%:3306/@$$%',username='@#$%',password='@#$%',tableName='sls_event');CREATE RESULT TABLE sls_status (time INT,event_type STRING,event_value STRING,value INT ) WITH (type='mysql',url='jdbc:mysql://@#$%:3306/@$$%',username='@#$%',password='@#$%',tableName='sls_event');
-- 3. 定义下计算逻辑
INSERT INTO sls_event select prop_get('__time__') as time, 'pv' as event_type, 'get' as event_value, COUNT(1) as valueFROM source_test_sls_galaxyGROUP BY prop_get('__time__');INSERT INTO sls_status select prop_get('__time__') as time, 'status' as event_type, status as event_value, COUNT(1) as valueFROM source_test_sls_galaxyGROUP BY prop_get('__time__'),status;
转载地址:http://icbll.baihongyu.com/