Transit router (TR) flow logs capture traffic information for your network instance connections. You can deliver the logs to NIS Traffic Analyzer or Simple Log Service (SLS) for analysis to monitor network performance, troubleshoot network issues, or optimize traffic costs.
How it works
Flow logs capture network traffic information outside the data path without affecting network performance. The workflow is as follows:
-
Traffic capture: Monitors IP traffic that flows through a specified resource, such as a VPC connection, an inter-region connection, or an entire transit router instance.
-
Data aggregation: Within a preset aggregation interval (1 minute or 10 minutes), the system aggregates packet information based on the traffic's five-tuple (source/destination IP address, source/destination port, and protocol) and counts the total bytes and packets.
-
Log delivery: After the aggregation interval ends, the system delivers the aggregated traffic statistics as a log record to the specified NIS Traffic Analyzer or Simple Log Service.
-
Analysis and query: Query or analyze the flow logs in the NIS or SLS console.
For example, if you deliver logs to SLS, you can view detailed traffic information for each network instance connection, analyze traffic that does not match any routes, and analyze traffic that matches a blackhole route.
Delivery destinations
-
Recommendations:
-
For quick analysis, we recommend that you deliver logs to NIS Traffic Analyzer.
-
For in-depth analysis scenarios, such as custom SQL queries, custom reports, and raw log queries, we recommend that you deliver logs to Simple Log Service.
-
-
Comparison:
Item
NIS Traffic Analyzer
Simple Log Service
Technical expertise
Low, featuring simple operations, a user-friendly interface, and a fast learning curve.
High (requires familiarity with SQL queries)
Flexibility
Limited. Analysis is restricted to a pre-built interface.
High. Allows for custom analysis by using SQL statements.
Custom reports
Not supported
Supported. You can create custom charts from query results.
Cost
NIS charges processing and storage fees for flow logs.
SLS charges for data writes, storage, and other items.
Capture direction
The capture direction of traffic information varies based on the resource:
Inter-region connection: Only outbound traffic from the current transit router is captured (the
directionfield isout). To capture bidirectional traffic, you must also enable the flow log for the inter-region connection on the peer transit router.VPC, VPN, ECR, and VBR connections: Both inbound (the
directionfield isin) and outbound (thedirectionfield isout) traffic are captured.TR: Captures traffic of all network instance connections created on the transit router. The capture direction follows the preceding rules.
Fields
Flow logs capture traffic on a best-effort basis, so some fields in a log record may be empty. A field might be empty if the resource does not support it, or if the traffic does not contain the corresponding information.
Limitations
-
Only Enterprise Edition transit routers support flow logs. If you are using a Basic Edition transit router, you must first upgrade it.
-
Flow logs do not support capturing multicast traffic.
-
To prevent TCP scan attacks from generating excessive logs, flow logs do not record TCP connections consisting only of connection establishment, reset, or termination packets.
For example, a connection is not logged if the three-way handshake is not completed or if a client's connection request is reset by a firewall.
-
Existing flow logs cannot be automatically upgraded. To use fields from a newer version, you must delete the existing flow log and create a new one. New instances automatically use the latest version and are backward-compatible. You can check the version of a flow log in the Cloud Enterprise Network console.
Create a flow log
Console
-
Go to the Cloud Enterprise Network console. On the details page of the target transit router, click the Flow Logs tab.
-
Click Create Flow Log. In the Create Flow Log dialog box, configure the following parameters:
-
Collection Configuration:
-
Instance: Select the target resource to monitor. The capture direction varies based on the resource type.
-
Sampling Interval: The length of the aggregation interval for collecting traffic information. You can select 1 minute or 10 minutes. A shorter interval provides more timely data, which helps you detect and resolve issues faster. A longer interval reduces log entries and saves costs, but it also increases data latency.
ImportantIf you choose to deliver logs to NIS Traffic Analyzer, the sampling interval of the flow log must be less than or equal to the sampling interval of the target traffic analyzer. Otherwise, the delivery fails.
-
-
Analysis and Delivery:
-
Select Mode: Select one or more delivery destinations. You must select at least one.
-
Enable NIS Traffic Analysis: You must Select NIS Traffic Analyzer.
Only some regions support delivering TR flow logs to NIS Traffic Analyzer.
-
Deliver to Simple Log Service: Select a target Log Service Project and Log Service Logstore. You can also create new ones on the fly.
-
-
Log Format: Select the fields to record in the flow log.
-
Default Format: Uses the fields selected by the system by default.
-
Custom Format: Customize the fields to record. This format supports more fields than the default format. Selecting fewer fields can simplify log information and reduce costs. The
srcaddr,dstaddr, andbytesfields are required.After you select a log format, the system automatically generates the format as a string in the text box below. Click Copy Selected Formats to create multiple flow logs with the same format by using the API.
-
-
-
API
Call the CreateFlowlog operation to create a flow log.
Analyze flow logs
After a flow log is created, it is in the Active state by default. You can start to analyze the logs:
-
Analyze flow logs in NIS Traffic Analyzer
In the NIS Traffic Analyzer column of the target flow log instance, click the traffic analyzer ID to go to the NIS console for query and analysis.
-
Analyze flow logs in Simple Log Service
After a flow log is created, Simple Log Service requires several minutes to initialize before it begins recording traffic information. In the Log Service column of the target flow log instance, click the Project and Logstore names to go to the SLS console to query and analyze the logs. For more information about how to analyze logs, see the following topics:
-
Tutorial: Query top inter-region traffic by using flow logs.
-
Operation guide: Quick start for SLS query and analysis.
-
Manage flow logs
Console
-
Modify a flow log:
-
Modify the sampling interval of a flow log: In the Sampling Interval (Minutes) column of the target flow log, click Modify.
-
Modify the delivery destination of a flow log: You cannot modify the delivery destination directly. Instead, click Modify Delivery Configuration in the Actions column. This process replaces the original flow log with a new one that has the updated settings.
-
-
Stop a flow log: After you stop a flow log, the system stops delivering logs to NIS or SLS.
In the Actions column of the target flow log, click Stop. You can click Start later to restart it.
-
Delete a flow log: Deleting a flow log removes only the collection task. Traffic information that has already been delivered to NIS or SLS and is within the storage period is not deleted. Before deleting a flow log, ensure that its data source has been removed from the NIS Traffic Analyzer.
In the Actions column of the target flow log, click Delete.
API
-
Modify a flow log:
-
To modify the sampling interval of a flow log, call the ModifyFlowLogAttribute operation.
-
To modify the delivery destination of a flow log, you must delete the existing flow log and create a new one. You cannot directly modify the destination.
-
-
Stop a flow log: Call the DeactiveFlowLog operation to stop a flow log. You can later call the ActiveFlowLog operation to restart it.
-
Delete a flow log: Call the DeleteFlowlog operation to delete a flow log.
Billing
TR flow logs incur two types of fees:
-
Network log extraction fee: This fee is for collecting flow logs by the transit router. This fee is currently waived. You will be notified before it is officially charged.
-
Destination service fees: The destination service begins to charge fees after flow logs are delivered.
-
NIS Traffic Analyzer: Fees are charged by NIS after flow logs are delivered to an NIS Traffic Analyzer. These include processing and storage fees.
-
Simple Log Service: Fees are charged by SLS after flow logs are delivered to SLS. These include fees for data writes and storage.
SLS offers two billing methods: pay-by-data-written and pay-by-feature. When you create a flow log in the Cloud Enterprise Network console and choose to create a new Logstore, the pay-by-feature method is used by default.
-
Supported regions
-
Regions that support delivering TR flow logs to NIS Traffic Analyzer:
China (Hangzhou), China (Shanghai), China (Shenzhen), China (Guangzhou), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Chengdu), Singapore, China (Hong Kong), Malaysia (Kuala Lumpur), Indonesia (Jakarta), Japan (Tokyo), South Korea (Seoul), Thailand (Bangkok), Germany (Frankfurt), UK (London), US (Virginia), and US (Silicon Valley).
-
Regions that support delivering TR flow logs to Simple Log Service:
All regions that support the creation of Enterprise Edition TRs.
Best practices
-
Balance cost and granularity: During initial deployment or troubleshooting, use a
1 minutesampling interval to obtain fine-grained data. For routine monitoring, you can use a10 minuteinterval to reduce log volume and costs. -
Use granular monitoring: Create separate flow logs for VPC connections that carry critical business traffic instead of enabling logging for the entire TR instance. This reduces unnecessary log data and lowers costs.
-
Choose a single destination: To reduce costs, select either NIS or SLS as the destination, but not both.
FAQ
Why is the "Flow Logs" tab missing?
This feature is available only for Enterprise Edition transit routers. First, confirm the edition of your transit router. If it is a Basic Edition, you must upgrade it to the Enterprise Edition to use this feature.
Why is there no data in SLS?
Follow these steps to troubleshoot the issue:
-
Check the flow log status: Make sure the flow log instance is in the Active state.
-
Wait for initialization: A newly created flow log needs a few minutes to initialize before it can start recording data.
-
Confirm network traffic: Verify that IP traffic is passing through the monitored resource. Logs are not generated if there is no traffic.
-
Check the query time range: In the Simple Log Service console, ensure that you have selected the correct time range for your query and consider that log delivery may have a delay of several minutes.
How to upgrade a flow log?
You cannot directly upgrade an existing flow log. To use the latest fields, you must delete the existing instance and create a new one. The new instance will automatically use the latest version and include all fields.