Last active
May 17, 2020 09:40
-
-
Save fairytalelin/e6be097a897d38b816bfe91f7ca8c0d4 to your computer and use it in GitHub Desktop.
ddl sql代码问题
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE yy_yapmnetwork_original ( | |
happenAt BIGINT, | |
uid BIGINT, | |
appId STRING, | |
deviceId STRING, | |
appVer STRING, | |
dnsDur BIGINT, | |
useGlb INT, | |
hitCache INT, | |
requestSize DOUBLE, | |
responseSize DOUBLE, | |
totalDur BIGINT, | |
url STRING, | |
statusCode INT, | |
prototype STRING, | |
netType STRING, | |
traceId STRING, | |
ts AS CAST(FROM_UNIXTIME(happenAt/1000) AS TIMESTAMP(3)), | |
WATERMARK FOR ts AS ts - INTERVAL '20' SECOND | |
)with ( | |
'connector.type' = 'kafka', | |
'connector.version' = 'universal', | |
'connector.topic' = 'yapm_metrics', | |
'connector.properties.zookeeper.connect' = 'localhost:2181', | |
'connector.properties.bootstrap.servers' = 'kafkawx007-core001.yy.com:8101,kafkawx007-core002.yy.com:8101,kafkawx007-core003.yy.com:8101', | |
'connector.properties.group.id' = 'interface_success_rate_consumer', | |
'connector.startup-mode' = 'latest-offset', | |
'format.type' = 'json' | |
); | |
create table request_latency_tbl ( | |
app_id string, | |
app_ver string, | |
net_type string, | |
prototype string, | |
url string, | |
status_code int, | |
w_start string, | |
success_cnt BIGINT, | |
failure_cnt BIGINT, | |
total_cnt BIGINT | |
) with( | |
'connector.type' = 'jdbc', | |
'connector.url' = 'jdbc:mysql://10.25.64.202:6307/yapm_metrics?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true', | |
'connector.table' = 'request_latency_statistics', | |
'connector.username' = 'yapm_metrics', | |
'connector.password' = 'whWoZqYe71', | |
'connector.write.flush.max-rows' = '1000', | |
'connector.write.flush.interval' = '5s', | |
'connector.write.max-retries' = '2' | |
); | |
create view request_1minutes_latency as | |
select appId, appVer, netType, prototype, url, statusCode, DATE_FORMAT(ts, 'yyyy-MM-dd HH:mm') w_start, | |
count(distinct traceId) filter (where statusCode in (200)) as successCnt, | |
count(distinct traceId) filter (where statusCode not in (200)) as failureCnt, | |
count(distinct traceId) as total_cnt | |
from yy_yapmnetwork_original group by appId, appVer, netType, prototype, url, statusCode, DATE_FORMAT(ts, 'yyyy-MM-dd HH:mm'); | |
insert into request_latency_tbl | |
select * from request_1minutes_latency; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment