建立流日誌。
介面說明
流日誌可以協助您擷取轉發路由器執行個體與網路執行個體連線(跨地域連線、VPC 連線、VPN 連線、ECR 連線及 VBR 連線)傳輸的流量資訊。在建立流日誌前,請先了解以下說明:
-
僅企業版轉發路由器支援建立流日誌。
-
對於跨地域連線的流量資訊,流日誌僅擷取轉發路由器出方向的流量資訊,不支援擷取轉發路由器入方向的流量資訊。
例如,美國(矽谷)地域的雲端伺服器 ECS(Elastic Compute Service)執行個體透過雲企業網存取美國(維吉尼亞)地域的 ECS 執行個體,在您為美國(維吉尼亞)地域的轉發路由器設定流日誌後,您可以在日誌服務主控台檢視美國(維吉尼亞)ECS 執行個體向美國(矽谷)ECS 執行個體傳送的封包資訊,但無法檢視美國(矽谷)ECS 執行個體向美國(維吉尼亞)ECS 執行個體傳送的封包資訊。如果您需要檢視美國(矽谷)ECS 執行個體向美國(維吉尼亞)ECS 執行個體傳送的封包資訊,您需要在美國(矽谷)地域的轉發路由器上也設定流日誌。
-
流日誌擷取 VPC 連線的流量資訊時,僅擷取轉發路由器 ENI 傳輸的流量資訊,如果您需要了解 VPC 內其他 ENI 傳輸的流量資訊,請參閱VPC 流日誌概述。
-
CreateFlowlog介面屬於非同步介面,即系統會先返回一個流日誌 ID,但是流日誌並未建立完成,系統背景的建立任務仍在進行。您可以呼叫DescribeFlowlogs介面查詢流日誌的狀態。當流日誌處於 Creating 狀態時,表示流日誌正在建立中,在該狀態下,您只能執行查詢操作,不能執行其他操作。
當流日誌處於 Active 狀態時,表示流日誌建立完成。
前提條件
為資源建立流日誌前,請確保您已經擁有了相關資源。各個資源的建立操作,請參閱:
調試
您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。
調試
授權資訊
|
操作 |
存取層級 |
資源類型 |
條件關鍵字 |
關聯操作 |
|
cen:CreateFlowlog |
create |
*All Resource
|
無 | 無 |
請求參數
|
名稱 |
類型 |
必填 |
描述 |
樣本值 |
| ClientToken |
string |
否 |
用戶端 Token,用於保證請求的冪等性。 從您的用戶端產生一個參數值,確保不同請求間該參數值唯一。ClientToken 只支援 ASCII 字元。 說明
若您未指定,則系統自動使用 API 請求的 RequestId 作為 ClientToken 識別碼。每次 API 請求的 RequestId 可能不一樣。 |
123e4567-e89b-12d3-a456-42665544**** |
| RegionId |
string |
是 |
流日誌所屬的地域 ID。 您可以透過呼叫 DescribeChildInstanceRegions 介面取得地域 ID。 |
cn-hangzhou |
| FlowLogName |
string |
否 |
流日誌名稱。 名稱可以為空或長度為 1~128 個字元,不能以 http:// 或 https:// 開頭。 |
myFlowlog |
| Description |
string |
否 |
流日誌的描述資訊。 描述可以為空或長度為 1~256 個字元,不能以 http:// 或 https:// 開頭。 |
myFlowlog |
| CenId |
string |
是 |
雲企業網執行個體 ID。 |
cen-7qthudw0ll6jmc**** |
| ProjectName |
string |
否 |
儲存擷取流量的 Project。
|
flowlog-project |
| LogStoreName |
string |
否 |
儲存擷取流量的 Logstore。
|
flowlog-logstore |
| Interval |
integer |
否 |
流日誌擷取流量的擷取視窗時長。單位:秒。取值:60 或 600。預設值:600。 |
600 |
| TransitRouterAttachmentId |
string |
否 |
VPC 連線、VPN 連線、VBR 連線、ECR 連線或跨地域連線 ID。 若需設定轉發路由器執行個體的流日誌,此欄位不填值。 |
tr-attach-r6g0m3epjehw57**** |
| TransitRouterId |
string |
否 |
轉發路由器執行個體 ID。 |
tr-bp1rmwxnk221e3fas**** |
| LogFormatString |
string |
否 |
自訂流日誌記錄欄位的字串。 格式定義為:
|
${srcaddr}${dstaddr}${bytes} |
| Tag |
array<object> |
否 |
標籤資訊。 一次最多支援輸入 20 個標籤資訊。 |
|
|
object |
否 |
標籤資訊。 一次最多支援輸入 20 個標籤資訊。 |
||
| Key |
string |
否 |
資源的標籤鍵。 一旦傳入該值,則不允許為空字串。最多支援 64 個字元,不能以 一次最多支援輸入 20 個標籤的標籤鍵。 |
TagKey |
| Value |
string |
否 |
資源的標籤值。 標籤值可以為空或輸入不超過 128 個字元的字串,不能以 每一個標籤鍵對應一個標籤值,一次最多支援輸入 20 個標籤鍵對應的標籤值。 |
TagValue |
返回參數
|
名稱 |
類型 |
描述 |
樣本值 |
|
object |
返回結果。 |
||
| RequestId |
string |
請求 ID。 |
54B48E3D-DF70-471B-AA93-08E683A1B457 |
| Success |
string |
目前介面呼叫是否成功。
|
true |
| FlowLogId |
string |
流日誌 ID。 |
flowlog-m5evbtbpt**** |
樣本
正常返回樣本
JSON格式
{
"RequestId": "54B48E3D-DF70-471B-AA93-08E683A1B457",
"Success": "true",
"FlowLogId": "flowlog-m5evbtbpt****"
}
錯誤碼
|
HTTP status code |
錯誤碼 |
錯誤資訊 |
描述 |
|---|---|---|---|
| 400 | ProjectOrLogstoreNotExist | The specified project or logstore does not exist. | 參數中指定的 project 或 logstore 不存在。 |
| 400 | SourceProjectNotExist | The Source Project or logstore does not exist. | SourceProject 或 logstore 不存在。 |
| 400 | OperationUnsupported.action | This action is not support. | 目前區域不支援此操作。 |
| 400 | RuleExist | The rule has already existed. | 該規則已存在。 |
| 400 | QuotaExceeded.FlowlogCount | This user has reached the maximum instance number of flowlog. | flowlog 數量已達到上限。 |
| 400 | InvalidFlowlogId.exist | This cenId already has flowlog instance existed. | 目前 CEN 已經存在 flowlog,無法操作。 |
| 400 | Flowlog.AlreayExist | This attachment already has existed flowlog instance. | flowlog 已存在,無法重複建立。 |
| 400 | IllegalParam.TransitRouterAttachmentId | TransitRouterAttachmentId is illegal. | 參數中指定的 TrInstance 不合法。 |
| 400 | InvalidTransitRouterAttachmentId.NotFound | The TransitRouterAttachmentId is not found. | 參數中指定的 TransitRouterAttachmentId 不存在。 |
| 400 | IncorrectStatus.flowlog | This action is not allowed in the current flow log status. | 當前 FlowLog 的狀態不支援該操作,請稍後重試。 |
| 400 | InvalidOperation.TransitRouterNotExist | Operation is invalid because the transit router not exist. | 轉發路由器不存在。 |
| 400 | IncorrectStatus.TransitRouterAttachmentId | The resource is not in a valid state for the attachment operation. | 目前該 Attachment 未處於穩定狀態,不支援此操作。 |
| 400 | ProjectExist | Project already exist, please try a different project name. | 日誌 Project 已存在,請嘗試使用不同的 Project 名稱。 |
| 400 | InvalidParameter.ProjectName | Project name is invalid or does not belong to specified region. | Project 名稱不合法。 |
| 400 | IncorrectStatus.TrFlowlog | Flowlog status for specified TransitRouter is invalid for this operation. | 指定轉送路由器的流日誌設定狀態無效。 |
| 400 | OperationInvalid.IncompatibleFlowlogExist | Operation is invalid because incompatible flowlog config exists. | 存在不相容的 Flowlog 設定,請刪除後重試。 |
| 400 | InvalidParameter.LogFormatString | LogFormatString is invalid. | 指定的日誌格式不合法。 |
| 400 | InvalidParameter.LogStoreName | Specified LogStore name is invalid. | Logstore 名稱不合法。 |
| 400 | OperationFailed.InvalidLogInfo | The entered log service information is invalid. Check whether the ProjectName and LogStoreName are correct, and whether Log Service has been activated. | 輸入的日誌服務資訊不合法。請確認 ProjectName 以及 LogStoreName 是否正確,並確認是否已啟用日誌服務。 |
| 400 | IncorrectStatus.TransitRouterInstance | The status of TransitRouter is incorrect. | 轉送路由器狀態不正確。 |
| 400 | InvalidParameter | Invalid parameter. | 參數不合法。 |
| 400 | Unauthorized | The AccessKeyId is unauthorized. | 帳號無權限操作。 |
| 400 | InvalidParameter.CenId | The specified parameter CenId is invalid. | |
| 400 | InvalidParameter.TagValue | The specified parameter TagValue is invalid. | 輸入的參數 Tag Value 不合法。 |
| 403 | NoPermission.AliyunServiceRoleForTRFlowLog | You are not authorized to create service linked role AliyunServiceRoleForTRFlowLog. | 無權限建立服務連結角色 AliyunServiceRoleForTRFlowLog。 |
訪問錯誤中心查看更多錯誤碼。
變更歷史
更多資訊,參考變更詳情。