Azure Lei Zhang的博客

weibo: LeiZhang的微博/QQ: 185165016/QQ群:319036205/邮箱:leizhang1984@outlook.com/TeL:139-161-22926

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

  《Windows Azure Platform 系列文章目录

 

  在Azure虚拟机监控里,是可以查看到入站流量(Network In)和出站流量(Network Out)。截图略。

  但是这些流量是Azure虚拟机网卡上的所有流量,不能查看到具体是内网流量,还是公网(互联网)流量。

  我们可以通过设置Azure 网络观察程序(Azure Network Watcher),启用NSG流日志,来查看具体的内网和公网流量。

 

  1.首先我们先创建1个Azure Network Watcher(网络观察程序),步骤略。

  2.在概述里,选择订阅,选择该订阅下的某些Azure数据中心,点击下图的红色...,在该Azure数据中心启用Network Watcher

  

 

  4.在NSG流日志里,选择订阅,选择资源组,然后选择到具体的虚拟机(或者虚拟网络子网的),所在的网络安全组。如下图:

  

 

  5.页面跳转,我们打开流日志。把流日志保存到Azure Storage里,同时我们把流量分析状态推送到Azure Log Analytics工作区里。如下图:

  

 

  6.我们等待一段时间,让NSG流日志把数据推送到Azure Log Analytics里

  7.然后我们打开Azure Log Analytics里,

  我们按照时间顺序,查看网络安全组叫temp-nsg,所有的网络流量情况

  具体Kusto语句:

AzureNetworkAnalytics_CL
| where NSGList_s contains "temp-nsg" and FASchemaVersion_s == '2' 
| project FlowStartTime_t, NSGRule_s, SrcIP_s, DestIP_s, DestPort_d, VM1_s, VM2_s, Subnet1_s, Subnet2_s, Country_s, SrcPublicIPs_s, DestPublicIPs_s, InboundBytes_d, OutboundBytes_d, InboundPackets_d, OutboundPackets_d, TimeGenerated
| order by TimeGenerated desc

 

  8.如果我们想看到一段时间内的,所有入站流量和出站流量的聚合数据,可以执行下面的kusto语句:

AzureNetworkAnalytics_CL
| where NSGList_s contains "temp-nsg" and FASchemaVersion_s == '2' 
| project FlowStartTime_t, NSGRule_s, SrcIP_s, DestIP_s, DestPort_d, VM1_s, VM2_s, Subnet1_s, Subnet2_s, Country_s, SrcPublicIPs_s, DestPublicIPs_s, InboundBytes_d, OutboundBytes_d, InboundPackets_d, OutboundPackets_d, TimeGenerated
| summarize outbound= sum(OutboundBytes_d),inbound=sum(InboundBytes_d)

 

  9.我们还可以在下图中,选择查询时间范围,并把查询结果下载为CSV文件

 

 

 

  

  

posted on 2022-02-24 21:18  Lei Zhang的博客  阅读(1050)  评论(0编辑  收藏  举报