${timeGranularity}= run keyword if '${timeGranularity}'=="${None}" and '${apiName}'=="injectionstatics" set variable 30
... ELSE set variable ${timeGranularity}
log ${apiName}
#topn排序依据: \ sessions、totalbytes、totalpackets
${TotalOrderBy}= run keyword if '${orderBy}'=="bytes" and '${apiName}'=="topn" set variable totalBytes
... ELSE IF '${orderBy}'=="packets" and '${apiName}'=="topn" set variable totalPackets
... ELSE IF '${orderBy}'=="sessions" and '${apiName}'=="topn" set variable sessions
#BigData
#BigData
${sql}= run keyword if '${apiName}'=="country" Set Variable SELECT country, APPROX_COUNT_DISTINCT_DS_HLL(ip_object) as num FROM source_country_ip_num_log where ${where} group by country order by num desc limit ${limit}
${sql}= run keyword if '${apiName}'=="country" Set Variable SELECT country, APPROX_COUNT_DISTINCT_DS_HLL(ip_object) as num FROM source_country_ip_num_log where ${where} group by country order by num desc limit ${limit}
... ELSE IF '${apiName}'=="domain" Set Variable SELECT domain, protocol_type, ip_num, session_num \ FROM top_domain_recommend_daily_log where __time = '${statisticTime}'
... ELSE IF '${apiName}'=="domain" Set Variable SELECT domain, protocol_type, ip_num, session_num \ FROM top_domain_recommend_daily_log where __time = '${statisticTime}'
@@ -64,7 +85,12 @@ GetApi
... ELSE IF '${apiName}'=="traffic" and '${statisticsUnit}'=='${None}' Set Variable select sum(total_in_bytes) as trafficInBytes, sum(total_out_bytes) as trafficOutBytes, \ sum(total_in_bytes+total_out_bytes) as trafficTotalBytes, sum(total_in_packets) as trafficInPackets,sum(total_out_packets) as trafficOutPackets,sum(total_in_packets+total_out_packets) as trafficTotalPackets, sum(new_conn_num) as sessions from traffic_metrics_log where __time >= '${startTime}' and __time < '${endTime}'
... ELSE IF '${apiName}'=="traffic" and '${statisticsUnit}'=='${None}' Set Variable select sum(total_in_bytes) as trafficInBytes, sum(total_out_bytes) as trafficOutBytes, \ sum(total_in_bytes+total_out_bytes) as trafficTotalBytes, sum(total_in_packets) as trafficInPackets,sum(total_out_packets) as trafficOutPackets,sum(total_in_packets+total_out_packets) as trafficTotalPackets, sum(new_conn_num) as sessions from traffic_metrics_log where __time >= '${startTime}' and __time < '${endTime}'
... ELSE IF '${apiName}'=="ip_correlation_domain" and '${ip}'!='${None}' Set Variable SELECT \ ip, FROM_UNIXTIME(max(stat_time)) as last_time, FROM_UNIXTIME(min(stat_time)) as first_time, groupUniqArrayMerge(domain_list) as domain_list, groupUniqArrayMerge(port_list) as port_list \ FROM security_ip_info where \ stat_time >= '${startTime}' and stat_time < '${endTime}' and ip='${ip}' group by ip
... ELSE IF '${apiName}'=="ip_correlation_domain" and '${ip}'!='${None}' Set Variable SELECT \ ip, FROM_UNIXTIME(max(stat_time)) as last_time, FROM_UNIXTIME(min(stat_time)) as first_time, groupUniqArrayMerge(domain_list) as domain_list, groupUniqArrayMerge(port_list) as port_list \ FROM security_ip_info where \ stat_time >= '${startTime}' and stat_time < '${endTime}' and ip='${ip}' group by ip
... ELSE IF '${apiName}'=="ip_correlation_domain" and ${ip}==${None} Set Variable SELECT ip,FROM_UNIXTIME(max(stat_time)) as last_time, FROM_UNIXTIME(min(stat_time)) as first_time, groupUniqArrayMerge(domain_list) as domain_list, groupUniqArrayMerge(port_list) as port_list \ FROM security_ip_info where \ stat_time >= '${startTime}' and stat_time < '${endTime}' \ group by ip
... ELSE IF '${apiName}'=="ip_correlation_domain" and ${ip}==${None} Set Variable SELECT ip,FROM_UNIXTIME(max(stat_time)) as last_time, FROM_UNIXTIME(min(stat_time)) as first_time, groupUniqArrayMerge(domain_list) as domain_list, groupUniqArrayMerge(port_list) as port_list \ FROM security_ip_info where \ stat_time >= '${startTime}' and stat_time < '${endTime}' \ group by ip
... ELSE IF '${apiName}'=="hijack_srcip_num" Set Variable SELECT policy_id,country,location, APPROX_COUNT_DISTINCT_DS_HLL(ip_object) as num \ FROM proxy_event_hits_log where \ __time >='${startTime}' and __time <'${endTime}' and policy_id in \ ( ${policy_ids} ) group by policy_id , country,location order by num desc
... ELSE IF '${apiName}'=="hijack_srcip_location" Set Variable select ip, IP_TO_CITY(ip) as location, IP_TO_GEO(ip) as geo from (SELECT policy_id, arrayJoin(groupUniqArrayMerge(ip_list)) as ip FROM proxy_ip_info where \ stat_time >= '${startTime}' and stat_time < '${endTime}' and policy_id = ${policy_id} group by policy_id )
... ELSE IF '${apiName}'=="hijack_srcip_location" Set Variable select ip, IP_TO_CITY(ip) as location, IP_TO_GEO(ip) as geo from (SELECT policy_id, arrayJoin(groupUniqArrayMerge(ip_list)) as ip FROM proxy_ip_info where \ stat_time >= '${startTime}' and stat_time < '${endTime}' and policy_id = ${policy_id} group by policy_id )
... ELSE IF '${apiName}'=="domain_resource" Set Variable SELECT \ domain, groupUniqArrayMerge(ip_list) as ip_list, groupUniqArrayMerge(cdn_list) as cdn_list, groupUniqArrayMerge(protocol_type_list) as protocol_type_list, groupUniqArrayMerge(port_list) as port_list \ FROM security_website_domain_info where \ stat_time >= '${startTime}' and stat_time < '${endTime}' and policy_id=${policy_id} group by domain
... ELSE IF '${apiName}'=="injectionstatistics" Set Variable select DATE_FORMAT(FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(__time)/${timeGranularity})*${timeGranularity}),'%Y-%m-%d %H:%i:%s') as stat_time, \ sum(bytes) as bytes from injection_metrics_log \ where __time >= '${startTime}' and __time < '${endTime}' group by DATE_FORMAT(FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(__time)/${timeGranularity})*${timeGranularity}),'%Y-%m-%d %H:%i:%s') limit ${limit}
... ELSE IF '${apiName}'=="topn" Set Variable select domain,sum(session_num) as sessions,sum(c2s_byte_num) as sentBytes,sum(s2c_byte_num) as receivedBytes,sum(c2s_byte_num+s2c_byte_num) as totalBytes,sum(c2s_pkt_num) as sentPackets,sum(s2c_pkt_num) as receivedPackets,sum(c2s_pkt_num+s2c_pkt_num) as totalPackets from top_website_domain_log where __time >= '${startTime}' \ and __time < '${endTime}' \ and order_by='${orderBy}' \ group by domain order by ${TotalOrderBy} desc limit ${limit}
log ${sql}
log sql------------${sql}
log sql------------${sql}
#traffic二次请求sql
#traffic二次请求sql
${sql2}= run keyword if '${apiName}'=='traffic' SplicingTrafficSql ${apiName} ${startTime} ${endTime} statisticsUnit=${statisticsUnit} timeGranularity=${timeGranularity} limit=${limit}
${sql2}= run keyword if '${apiName}'=='traffic' SplicingTrafficSql ${apiName} ${startTime} ${endTime} statisticsUnit=${statisticsUnit} timeGranularity=${timeGranularity} limit=${limit}
@@ -82,7 +108,7 @@ GetApi
... AND Should Be Equal As Strings ${bigdata2}[status] 200
... AND Should Be Equal As Strings ${bigdata2}[status] 200
#traffic二次请求json拼接与毕方一致
#traffic二次请求json拼接与毕方一致
${bigdataTraffic}= run keyword if '${apiName}'=="traffic" SplicingTrafficJson ${bigdata} ${bigdata2}
${bigdataTraffic}= run keyword if '${apiName}'=="traffic" SplicingTrafficJson ${bigdata} ${bigdata2}
${bifanglist} run keyword if '${apiName}'=="ip_correlation_domain" set variable ${bifang['data']['list']['list']}
${bifanglist} run keyword if '${apiName}'=="ip_correlation_domain" \ or '${apiName}'=='domain_resource' set variable ${bifang['data']['list']['list']}
... ELSE IF '${apiName}'=="traffic" set variable ${bifang['data']}
... ELSE IF '${apiName}'=="traffic" set variable ${bifang['data']}
... ELSE set variable ${bifang['data']['list']}
... ELSE set variable ${bifang['data']['list']}
${bigdatalist} run keyword if '${apiName}'=="traffic" set variable ${bigdataTraffic}
${bigdatalist} run keyword if '${apiName}'=="traffic" set variable ${bigdataTraffic}
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.