Collecting Logs from VPC

Scenario

Virtual Private Cloud (VPC) flow logs capture information about traffic going to and from your VPC. You can use flow logs to monitor network traffic, analyze network attacks, and determine whether security groups and firewall rules need to be modified.

To obtain traffic details of VPC Network Interface Cards (NICs), you can view flow logs about the NICs through LTS.

Precautions

  • Only S2, M2, HC2, H2, D2, P1, G3, PI1, FP1, S3, C3, M3, H3, D3, IR3, I3, SN3, S6, E3, C3ne, M3ne, G5, P2v, AI1, C6, M6, and D6 ECSs are supported.
  • Up to 10 VPC flow logs can be created by default.
  • Up to 400,000 flow log records are supported by default.
  • VPC flow logs are available for open beta test (OBT) in regions AP-Singapore, CN South-Guangzhou, and AP-Bangkok. If you want to use this function, apply for the OBT.

Prerequisites

  • You have created a log group.
  • You have created a log stream.

Procedure

  1. Log in to the management console.
  2. Click in the upper left corner to select the desired region and project.
  3. Choose Service List > Networking > Virtual Private Cloud.
  4. In the navigation pane on the left, choose VPC Flow Logs.
  5. In the upper right corner, click Create VPC Flow Log and configure the parameters in the dialog box displayed.
    Table 1 Parameter description

    Parameter

    Description

    Example Value

    Name

    VPC flow log name

    The name can contain up to 64 characters and cannot contain spaces. Only letters, numbers, underscores (_), hyphens (-), and periods (.) are allowed.

    flowlog-495d

    Resource Type

    Type of the resource whose traffic is to be logged. You can select NIC, Subnet, or VPC.

    NIC

    Resource

    Select the specific resource whose traffic is to be logged.

    NOTE:

    You are advised to select a running ECS. If you select a stopped ECS, restart the ECS after the VPC flow log is created so the resource traffic can be accurately recorded.

    -

    Filter

    • All traffic: Both accepted and rejected traffic of the specified resource will be logged.
    • Accepted traffic: Only accepted traffic of the specified resource will be logged. Accepted traffic refers to the traffic permitted by the access control rules.
    • Rejected traffic: Only rejected traffic of the specified resource will be logged. Rejected traffic refers to the traffic denied by the access control rules.

    All traffic

    Log Group

    Select an LTS log group.

    lts-group-wule

    Log Stream

    Select an LTS log stream.

    lts-groupstream1

    Description

    (Optional) Description about the VPC flow log.

    The description can contain up to 255 characters and cannot contain angle brackets (<>).

    -

  6. Click OK.
  7. View VPC flow logs in real time on the LTS console. You can also structure the flow logs for future query and analysis:
    1. On the log stream details page of the LTS console, click Log Configuration in the navigation pane and click the Log Structuring tab.
    2. Select Structuring Template, select the system template for VPC, and click Save. On the log structuring details page, you can enable Quick Analysis.