本文为您介绍流日志的使用示例。
您可通过流日志,查看ECS实例与公网互通的流量,如下图所示:
操作步骤如下:
参考上图创建网卡类型的流日志,并配置索引。
以ECS访问公网地址14.XX.XX.40
为例,输入以下SQL检索分析语句。
srcaddr:"192.168.1.22" and dstaddr: "14.XX.XX.40" | SELECT DATE_FORMAT(t, '%H:%i:%S') AS time, dstaddr, SUM((bytes * 8) / (`end` - start)) AS bandwidth FROM (SELECT `end`, start, dstaddr, bytes, (__time__ - (__time__ % 3600)) AS t limit 1000) GROUP BY time, dstaddr ORDER BY time ASC limit 1000
输入分析语句时,请您将源IP地址(ECS的地址)
192.168.1.22
和目的IP地址(公网地址)"14.XX.XX.40"
替换为实际的IP地址。
查看分析结果。
由上图可知,近15分钟内,ECS(192.168.1.22)访问公网IP地址(14.XX.XX.40)的流量呈波浪形变化。
您可通过流日志,查看同一私有网络内云服务器之间的互访流量,如下图所示:
操作步骤如下:
srcaddr:"192.168.1.11" and dstaddr: "192.168.1.22" | SELECT DATE_FORMAT(t, '%H:%i:%S') AS time, dstaddr, SUM((bytes * 8) / (`end` - start)) AS bandwidth FROM (SELECT `end`, start, dstaddr, bytes, (__time__ - (__time__ % 36000)) AS t limit 1000) GROUP BY time, dstaddr ORDER BY time ASC limit 1000
输入分析语句时,请您将源IP地址(ECS-A的地址)
192.168.1.11
和目的IP地址(ECS-B的地址)192.168.1.22
替换为实际的IP地址。
您可通过流日志,查看云上私有网络与本地IDC的互访流量,如下图所示:
操作步骤如下:
action: ACCEPT |SELECT COALESCE(vpc_A_traffic.minute, vpc_B_traffic.minute) AS minute, COALESCE(vpc_A_traffic.total_vpc_A_traffic, 0) * 100 / NULLIF(COALESCE(vpc_A_traffic.total_vpc_A_traffic, 0) + COALESCE(vpc_B_traffic.total_vpc_B_traffic, 0), 0) AS vpc_A_percentage, COALESCE(vpc_B_traffic.total_vpc_B_traffic, 0) * 100 / NULLIF(COALESCE(vpc_A_traffic.total_vpc_A_traffic, 0) + COALESCE(vpc_B_traffic.total_vpc_B_traffic, 0), 0) AS vpc_B_percentage FROM ( SELECT date_trunc('minute', __time__) AS minute, SUM (bytes * 8 / CASE WHEN "end" - start = 0 THEN 1 ELSE "end" - start END) AS total_vpc_A_traffic WHERE srcaddr LIKE '192.168.%' GROUP BY date_trunc('minute', __time__)) as vpc_A_traffic FULL JOIN ( SELECT date_trunc('minute', __time__) AS minute, SUM (bytes * 8 / CASE WHEN "end" - start = 0 THEN 1 ELSE "end" - start END) AS total_vpc_B_traffic WHERE srcaddr LIKE '172.16.%' GROUP BY date_trunc('minute', __time__)) as vpc_B_traffic ON vpc_A_traffic.minute = vpc_B_traffic.minute ORDER BY minute
输入分析语句时,请您根据实际VPC的地址段修改模糊匹配的
'192.168.%'
和'172.16.%'
字段。
您可通过流日志,查看被安全组、网络ACL拒绝的流量,如下图所示:
操作步骤如下:
dstaddr: 172.16.1.4 and action: "REJECT" | SELECT dstaddr,srcaddr, action ORDER BY dstaddr
输入分析语句时,请您将目的IP地址
172.16.1.4
替换为实际的IP地址。