Creates a flow log.
Usage notes
CreateFlowLog is an asynchronous operation. After a request is sent, the system returns a request ID and runs the task in the background. You can call the DescribeFlowLogs operation to query the status of the operation.
- If the flow log is in the Activating state, the flow log is being created.
- If the flow log is in the Active state, the flow log is created and started.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | CreateFlowLog | The operation that you want to perform. Set the value to CreateFlowLog. |
RegionId | String | Yes | cn-qingdao | The ID of the region where you want to create the flow log. You can call the DescribeRegions operation to query the most recent region list. |
FlowLogName | String | No | myFlowlog | The name of the flow log. The name must be 1 to 128 characters in length. The name cannot start with |
Description | String | No | This is my Flowlog. | The description of the flow log. The description must be 1 to 256 characters in length. The description cannot start with |
ResourceType | String | Yes | NetworkInterface | The type of resource whose traffic you want to capture. Valid values:
|
ResourceId | String | Yes | eni-askldfas**** | The ID of the resource whose traffic you want to capture. |
TrafficType | String | Yes | All | The type of traffic that you want to capture. Valid values:
|
ProjectName | String | Yes | FlowLogProject | The name of the project that stores the captured traffic data.
|
LogStoreName | String | Yes | FlowLogStore | The name of the Logstore that stores the captured traffic data.
|
AggregationInterval | Integer | No | 10 | The sampling interval of the flow log. Unit: minutes. Valid values: 1, 5, and 10 (default). |
TrafficPath.N | String | No | all | The scope of traffic that you want to capture. Valid values:
Note This feature is unavailable by default. If you want to use this feature, submit a ticket. |
ResourceGroupId | String | No | rg-acfmxazdjdhd**** | The ID of the resource group. |
Tag.N.Key | String | No | FinanceDept | The key of tag N to add to the resource. You can specify at most 20 tag keys. The tag key cannot be an empty string. The tag key can be up to 128 characters in length. It cannot start with |
Tag.N.Value | String | No | FinanceJoshua | The value of tag N to add to the resource. You can specify at most 20 tag values. The tag value can be an empty string. The tag value can be up to 128 characters in length, and cannot contain |
Response parameters
Parameter | Type | Example | Description |
RequestId | String | 54B48E3D-DF70-471B-AA93-08E683A1B457 | The request ID. |
Success | String | true | Indicates whether the operation is successful. Valid values:
|
FlowLogId | String | fl-m5e8vhz2t21sel1nq**** | The ID of the flow log. |
ResourceGroupId | String | rg-acfmxazdjdhd**** | The ID of the resource group. |
Examples
Sample requests
http(s)://[Endpoint]/?Action=CreateFlowLog
&RegionId=cn-qingdao
&FlowLogName=myFlowlog
&Description=This is my Flowlog.
&ResourceType=NetworkInterface
&ResourceId=eni-askldfas****
&TrafficType=All
&ProjectName=FlowLogProject
&LogStoreName=FlowLogStore
&AggregationInterval=10
&TrafficPath=["all"]
&ResourceGroupId=rg-acfmxazdjdhd****
&Tag=[{"Key":"FinanceDept","Value":"FinanceJoshua"}]
&Common request parameters
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateFlowLogResponse>
<RequestId>54B48E3D-DF70-471B-AA93-08E683A1B457</RequestId>
<Success>true</Success>
<FlowLogId>fl-m5e8vhz2t21sel1nq****</FlowLogId>
<ResourceGroupId>rg-acfmxazdjdhd****</ResourceGroupId>
</CreateFlowLogResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "54B48E3D-DF70-471B-AA93-08E683A1B457",
"Success" : "true",
"FlowLogId" : "fl-m5e8vhz2t21sel1nq****",
"ResourceGroupId" : "rg-acfmxazdjdhd****"
}
Error codes
HttpCode | Error code | Error message | Description |
400 | IncorrectBusinessStatus.FlowLog | The business status of flowLog is incorrect. | You cannot create flow logs in the current business state. |
400 | OptInRequired.FlowLog | You are not authorized to use the requested service of flowLog. Ensure that you have subscribed to the service you are trying to use. | You do not have the permissions to use the flow log feature. Make sure that you have subscribed to the service that you want to use. |
400 | OperationUnsupported.AdvancedFeature | Advanced features of the vpc is unsupported. | The advanced feature is not supported. |
400 | InvalidInstanceId | vswitch does not exist. | The vSwitch does not exist. |
400 | InvalidInstanceId | NetworkInterface does not exist. | The ENI does not exist. |
400 | InvalidInstanceId | VPC does not exists. | The VPC does not exist. |
400 | ProjectOrLogstoreNotExist | The specified project or logstore does not exist. | The specified project or Logstore does not exist. |
400 | SourceProjectNotExist | The Source Project or logstore does not exist. | The source project or Logstore does not exist. |
400 | Unauthorized | This api does not support sub user or role. | You cannot call this operation as a RAM user. |
400 | OperationUnsupported.action | This action is not support. | The operation is not supported. |
400 | ParameterInvalid | Invalid parameter. | A parameter is set to an invalid value. |
400 | QuotaExceeded.FlowlogCount | This user has reached the maximum instance number of flowlog. | The number of flow logs reaches the upper limit. |
400 | InvalidResourceId.NotFound | This resourceId already has flowlog instance existed. | A flow log is already enabled for the resource. |
400 | INVALID_PARAMETER | The parameter invalid. | A parameter is set to an invalid value. |
400 | MissingParameter | Missing mandatory parameter | Required parameters are not set. Check whether you have set all required parameters before you call this operation. |
400 | IllegalParam.AggregationInterval | The param of aggregationInterval is illegal. | The sampling interval is invalid. |
400 | UnsupportedFeature.UserDefinedTrafficPath | The feature of UserDefinedTrafficPath is not supported. | The current user does not have the permissions to specify TrafficPath.N. |
400 | IllegalParam.TrafficPath | The param of trafficPath is illegal. | TrafficPath.N is set to an invalid value. |
400 | DuplicatedParam.TrafficPath | The param of trafficPath is duplicated. | The value of TrafficPath.N is duplicate. |
400 | IllegalParam.ResourceGroupId | Invalid ResourceGroupld value. | The specified resource group is invalid or does not exist. |
For a list of error codes, see Service error codes.