MSDN Documentation

Network Security Group Flow Logs

Network Security Group (NSG) flow logs provide visibility into IP traffic flowing through an NSG. They allow you to record information about the inbound and outbound traffic. This data can be used to troubleshoot network connectivity and security issues, monitor traffic distribution, or validate network configuration.

What are NSG Flow Logs?

NSG flow logs capture the following information for each flow:

Enabling NSG Flow Logs

To enable NSG flow logs, you need to:

  1. Navigate to your Network Security Group in the Azure portal.
  2. Under Monitoring + Logging, select Flow logs.
  3. Toggle Status to On.
  4. Choose a Retention period (in days).
  5. Select a Storage account where the flow logs will be stored.
  6. Optionally, enable Traffic Analytics for richer insights.
Tip: For detailed steps and options, refer to the official Azure documentation on NSG flow logs.

Viewing and Analyzing Flow Logs

Once enabled, flow logs are stored in a storage account. You can access them directly or use tools like Azure Monitor, Log Analytics, or Azure Sentinel for analysis.

Using Log Analytics

Log Analytics provides a powerful querying interface (Kusto Query Language - KQL) to explore your flow log data.

Here's a sample KQL query to retrieve denied inbound traffic to a specific VM:


NSGFlowLogs
| where DestinationIP == "10.0.0.4"
| where FlowDirection == "Inbound"
| where Action == "Deny"
| project TimeGenerated, SourceIP, DestinationIP, DestinationPort, Protocol, Rule
| order by TimeGenerated desc
            

Traffic Analytics

Traffic Analytics processes NSG flow logs and visualizes traffic flow data in a dashboard. It helps identify network choke points, security threats, and compliance issues. It requires enabling NSG flow logs and selecting a Log Analytics workspace.

Key Use Cases

Note: NSG flow logs are charged based on the volume of data stored. Consider your retention policy carefully.

Common Flow Log Fields

Field Description
Timestamp The time the flow record was generated.
ResourceID The NSG resource ID.
FlowTuple A unique identifier for a flow record.
SourceIp The source IP address of the flow.
DestinationIp The destination IP address of the flow.
SourcePort The source port of the flow.
DestinationPort The destination port of the flow.
Protocol The protocol used by the flow (e.g., 6 for TCP, 17 for UDP).
Action The action taken on the flow (Allow or Deny).
FlowDirection The direction of the flow (Inbound or Outbound).
Rule The name of the NSG rule that processed the flow.
PacketsSent The number of packets sent.
PacketsReceived The number of packets received.
BytesSent The number of bytes sent.
BytesReceived The number of bytes received.
Important: NSG flow logs are not a replacement for network intrusion detection systems (NIDS) but complement them by providing flow-level data.

Related Articles