調用CreateCollector,建立採集器。
調試
您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。
要求標頭
該介面使用公用要求標頭,無特殊要求標頭。請參見公用請求參數文檔。
請求文法
POST /openapi/collectors HTTP/1.1
請求參數
| 名稱 | 類型 | 位置 | 是否必選 | 樣本值 | 描述 |
| clientToken | String | Query | 否 | 5A2CFF0E-5718-45B5-9D4D-70B3FF**** | 用於保證請求的等冪性。由用戶端產生該參數值,要保證在不同請求間唯一,最大不超過64個ASCII字元。 |
| Object | Body | 否 | 請求體參數。用來指定待建立採集器的配置資訊。 |
||
| dryRun | Boolean | Body | 是 | true | 是否校正並建立採集器,只有在建立或更新採集器時使用此參數。可選值:
|
| name | String | Body | 是 | ct-test | 採集器名稱。長度為1~30個字元,以大小寫字母開頭,可以包含字母、數字、底線(_)或連字號(-)。 |
| resType | String | Body | 是 | fileBeat | 採集器類型。可選值:fileBeat、metricBeat、heartBeat和auditBeat。 |
| vpcId | String | Body | 是 | vpc-bp12nu14urf0upaf***** | 採集器所在的專用網路ID。 |
| resVersion | String | Body | 是 | 6.8.5_with_community | 採集器版本。可選值:
|
| collectorPaths | Array of String | Body | 否 | ["/var/log"] | fileBeat採集路徑。僅當採集器的安裝機器為ECS時,需要配置。 |
| configs | Array | Body | 是 | 採集器的設定檔資訊。 |
|
| fileName | String | Body | 是 | filebeat.yml | 檔案名稱。 |
| content | String | Body | 是 | "filebeat.inputs:xxx" | 檔案內容。 |
| extendConfigs | Array of Object | Body | 是 | { "instanceId": "es-cn-nif201ihd0012****", "instanceType": "elasticsearch", "configType": "collectorTargetInstance", "hosts": [ "es-cn-nif201ihd0012****.elasticsearch.aliyuncs.com:9200" ], "userName": "elastic", "password": "*****", "protocol": "HTTP" }, { "type": "ECSInstanceId", "configType": "collectorDeployMachine", "machines": [ { "instanceId": "i-bp11u91xgubypcuz****" } ] } ] | 採集器擴充配置,詳情請參見下文的extendConfigs參數說明章節。 |
extendConfigs參數說明
extendConfigs中的參數含義如下。
名稱 |
類型 |
是否必選 |
樣本值 |
描述 |
extendConfigs |
Array |
採集器擴充配置。 |
||
└configType |
String |
是 |
collectorElasticsearchForKibana |
配置類型。可選值:collectorTargetInstance(採集器Output)、collectorDeployMachine(採集器的部署機器)、collectorElasticsearchForKibana(支援Kibana儀錶盤的Elasticsearch執行個體資訊)。 |
└type |
String |
否 |
ECSInstanceId |
採集器部署的機器類型。可選值:ECSInstanceId(ECS)、ACKCluster(容器Kubernetes)。當configType為collectorDeployMachine時必填。 |
└instanceType |
String |
否 |
elasticsearch |
採集器Output指定的執行個體類型。可選值:elasticsearch、logstash。當configType為collectorTargetInstance時必填。 |
└instanceId |
String |
是 |
es-cn-nif201ihd0012**** |
採集器關聯的執行個體ID。當configType為collectorTargetInstance時,為採集器Output的執行個體ID;當configType為collectorDeployMachines,且type為ACKCluster時,為ACK叢集ID。 |
└machines |
Array |
否 |
採集器所部署的ECS機器列表資訊。當configType為collectorDeployMachines,且type為ECSInstanceId時,必填。 |
|
└└instanceId |
String |
是 |
i-bp11u91xgubypcuz**** |
ECS機器ID列表。 |
└groupId |
String |
default_ct-cn-5i2l75bz4776**** |
機器組ID。當configType為collectorDeployMachine時,必填。 |
|
└protocol |
String |
否 |
HTTP |
傳輸協議,需要與採集器Output指定執行個體的訪問協議保持一致。可選值:HTTP、HTTPS。當configType為collectorTargetInstance時必填。 |
└userName |
String |
否 |
elastic |
採集器Output指定執行個體的訪問使用者名稱,預設為elastic。當configType為collectorTargetInstance或collectorElasticsearchForKibana時必填。 |
└password |
String |
否 |
***** |
對應使用者名稱的密碼。 |
└enableMonitoring |
Boolean |
否 |
true |
是否啟用Monitoring,當configType為collectorTargetInstance,且instanceType為elasticsearch時必填。可選值:true(啟用)、false(不啟用)。 |
└hosts |
List<String> |
否 |
["es-cn-nif201i*****.elasticsearch.aliyuncs.com:9200"] |
採集器Output指定執行個體的訪問地址清單。當configType為collectorTargetInstance時必填。 |
└host |
String |
否 |
es-cn-nif201ihd0012****-kibana.internal.elasticsearch.aliyuncs.com:5601 |
啟用Kibana Dashboard後,Kibana的私網訪問地址。當configType為collectorElasticsearchForKibana時必填。 |
└kibanaHost |
String |
否 |
https://es-cn-nif201ihd0012****.kibana.elasticsearch.aliyuncs.com:5601 |
啟用Kibana Dashboard後,Kibana的公網訪問地址。當configType為collectorElasticsearchForKibana時必填。 |
extendConfigs中包括3種configType,分別為collectorTargetInstance、collectorElasticsearchForKibana、collectorDeployMachine,部署機器不同,需要配置的參數不同,具體組合方式如下:
- collectorTargetInstance
-
ECS
configType、instanceId、instanceType、hosts、userName、password、protocol、enableMonitoring
-
ACK
configType、instanceId、instanceType、userName、password、protocol、enableMonitoring
-
- collectorElasticsearchForKibana
-
ECS
configType、instanceId、host、kibanaHost、userName、password、protocol
-
ACK
configType
-
- collectorDeployMachine
-
ECS
configType、type、machines、groupId
-
ACK
configType、type、instanceId
-
返回資料
| 名稱 | 類型 | 樣本值 | 描述 |
| RequestId | String | 8466BDFB-C513-4B8D-B4E3-5AB256AB**** | 請求ID。 |
| Result | Object | 返回結果。 |
|
| resId | String | ct-cn-4135is2tj194p**** | 建立成功的採集器ID。 |
樣本
請求樣本
POST /openapi/collectors?clientToken=5A2CFF0E-5718-45B5-9D4D-70B3FF**** HTTP/1.1
Host:elasticsearch.aliyuncs.com
Content-Type:application/json
{
"dryRun": false,
"name": "test_beats_1",
"resType": "fileBeat",
"resVersion": "6.8.5_with_community",
"vpcId": "vpc-bp12nu14urf0upaf*****",
"collectorPaths": [
"/var/log"
],
"extendConfigs": [
{
"instanceId": "es-cn-nif201ihd0012****",
"instanceType": "elasticsearch",
"configType": "collectorTargetInstance",
"hosts": [
"es-cn-nif201ihd0012****.elasticsearch.aliyuncs.com:9200"
],
"userName": "elastic",
"password": "*****",
"protocol": "HTTP"
},
{
"type": "ECSInstanceId",
"configType": "collectorDeployMachine",
"machines": [
{
"instanceId": "i-bp11u91xgubypcuz****"
}
]
}
],
"configs": [
{
"fileName": "filebeat.yml",
"content": "filebeat.inputs:xxx"
},
{
"fileName": "fields.yml",
"content": "- key: log\n title: Log file content\n description: >\n Contains log file lines.\n ...."
}
]
}
正常返回樣本
JSON格式
HTTP/1.1 200 OK
Content-Type:application/json
{
"Result" : {
"resId" : "ct-cn-4135is2tj194p****"
},
"RequestId" : "8466BDFB-C513-4B8D-B4E3-5AB256AB****"
}
錯誤碼
訪問錯誤中心查看更多錯誤碼。