创建采集器,采集指定服务上的数据。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
|
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
|
elasticsearch:CreateCollector |
create |
*全部资源
|
无 | 无 |
请求语法
POST /openapi/collectors HTTP/1.1
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| clientToken |
string |
否 |
用于保证请求的幂等性。由客户端生成该参数值,要保证在不同请求间唯一,最大不超过 64 个 ASCII 字符。 |
5A2CFF0E-5718-45B5-9D4D-70B3FF**** |
| body |
object |
否 |
请求体参数。用来指定待创建采集器的配置信息。 |
{ "dryRun": false, "name": "test_beats_1", "resType": "fileBeat", "resVersion": "6.8.5_with_community", "vpcId": "vpc-bp12nu14urf0upaf*****", "collectorPaths": [ "/var/log" ], "configs": [ { "fileName": "filebeat.yml", "content": "filebeat.inputs:xxx" } ] } |
| dryRun |
boolean |
是 |
是否校验并创建采集器,只有在创建或更新采集器时使用此参数。可选值:
|
true |
| name |
string |
是 |
采集器名称。长度为 1~30 个字符,以大小写字母开头,可以包含字母、数字、下划线(_)或连字符(-)。 |
ct-test |
| resType |
string |
是 |
采集器类型。可选值:fileBeat、metricBeat、heartBeat 和 auditBeat。 枚举值:
|
fileBeat |
| vpcId |
string |
是 |
采集器所在的专有网络 ID。 |
vpc-bp12nu14urf0upaf***** |
| resVersion |
string |
是 |
采集器版本。可选值:
枚举值:
|
6.8.5_with_community |
| collectorPaths |
array |
否 |
fileBeat 采集路径。仅当采集器的安装机器为 ECS 时,需要配置。 |
|
|
string |
否 |
fileBeat 采集路径。仅当采集器的安装机器为 ECS 时,需要配置。 |
["/var/log"] |
|
| configs |
array<object> |
是 |
采集器的配置文件信息。 |
|
|
object |
是 |
采集器的配置文件信息。 |
||
| fileName |
string |
是 |
文件名。 |
filebeat.yml |
| content |
string |
是 |
文件内容。 |
"filebeat.inputs:xxx" |
| extendConfigs |
array<object> |
是 |
采集器扩展配置。 |
|
|
object |
是 |
采集器扩展配置,详情请参见下文的 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****" } ] } ] |
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 | 否 | ["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
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
|||
| RequestId |
string |
请求 ID。 |
8466BDFB-C513-4B8D-B4E3-5AB256AB**** |
| Result |
object |
返回结果。 |
|
| resId |
string |
创建成功的采集器 ID。 |
ct-cn-4135is2tj194p**** |
示例
正常返回示例
JSON格式
{
"RequestId": "8466BDFB-C513-4B8D-B4E3-5AB256AB****",
"Result": {
"resId": "ct-cn-4135is2tj194p****"
}
}
错误码
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。