Creates a flow log.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateFlowLog

The operation that you want to perform. Set the value to CreateFlowLog.

LogStoreName String Yes FlowLogStore

The Logstore that stores the captured traffic data.

ProjectName String Yes FlowLogProject

The Project that stores the captured traffic data.

RegionId String Yes cn-qingdao

The region to which the flow log belongs. You can call the DescribeRegions operation to query the region IDs.

ResourceId String Yes eni-askldfasza23****

The ID of the resource whose traffic you want to capture. The IDs of virtual private clouds (VPCs), VSwitches, and elastic network interfaces (ENIs) are supported.

If the VPCs to which specified VSwitches or ENIs belong contain ECS instances of the following instance types, you cannot create flow logs for the VPCs, VSwitches, or ENIs:

ecs.c1, ecs.c2, ecs.c4, ecs.c5, ecs.ce4, ecs.cm4, ecs.d1, ecs.e3, ecs.e4, ecs.ga1, ecs.gn4, ecs.gn5, ecs.i1, ecs.m1, ecs.m2, ecs.mn4, ecs.n1, ecs.n2, ecs.n4, ecs.s1, ecs.s2, ecs.s3, ecs.se1, ecs.sn1, ecs.sn2, ecs.t1, and ecs.xn4.

To create a flow log, you must upgrade the instance. For more information, see Upgrade the instance types of subscription instances and Change the instance type of a pay-as-you-go instance.

Note If your VPC contains one instance of the preceding instance types and you have created a flow log, you must upgrade the instance to ensure that the flow log can function as expected.
ResourceType String Yes NetworkInterface

The type of the resource whose traffic you want to capture. Valid Values:

  • NetworkInterface: captures the flow log of an ENI.
  • VSwitch: captures the flow log of the VSwitch.
  • VPC: captures the flow log of a VPC.
TrafficType String Yes all

The type of the traffic that you want to capture. Valid values:

  • All: all traffic.
  • Allow: traffic that is allowed by access control.
  • Drop: traffic that is denied by access control.
FlowLogName String No myFlowlog

The name of the flow log.

The name must be 2 to 128 characters in length and start with a letter. The name can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name cannot start with http:// or https://.

Description String No This is my Flowlog

The description of the flow log.

The description must be 2 to 256 characters in length and start with a letter. The description cannot start with http:// or https://.

Response parameters

Parameter Type Example Description
FlowLogId String flowlog-m5evbtbptzsxdca****

The ID of the flow log.

RequestId String 54B48E3D-DF70-471B-AA93-08E683A1B457

The ID of the request.

Success String true

Indicates whether the call was successful.

true: The call was successful.

false: The call failed.

Examples

Sample requests

https://vpc.aliyuncs.com/?Action=CreateFlowLog
&LogStoreName=FlowLogStore
&ProjectName=FlowLogProject
&RegionId=cn-qingdao
&ResourceId=eni-askldfasza23****
&ResourceType=NetworkInterface
&TrafficType=all
&<Common request parameters>

Sample success responses

XML format

<CreateFlowLogResponse>
      <RequestId>54B48E3D-DF70-471B-AA93-08E683A1B457</RequestId>
      <FlowLogId>flowlog-m5evbtbptzsxdca****</FlowLogId>
</CreateFlowLogResponse>

JSON format

{
    "RequestId": "54B48E3D-DF70-471B-AA93-08E683A1B457",
    "FlowLogId": "flowlog-m5evbtbptzsxdca****"
}

Error codes

HttpCode Error code Error message Description
400 INVALID_PARAMETER The parameter invalid. The error message returned because the specified parameter is not valid.
400 MissingParameter Missing mandatory parameter The error message returned because the required parameters are missing. Check whether you have set all required parameters before you call this operation.

For a list of error codes, visit the API Error Center.