创建主机组
功能介绍
创建主机组
URI
POST /v3/{project_id}/lts/host-group
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| project_id | 是 | String | 项目ID,获取方式请参见:获取项目ID,获取账号ID,日志组ID、日志流ID 最小长度:1 最大长度:64 |
请求参数
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| X-Auth-Token | 是 | String | 从IAM服务获取的用户Token,获取方式请参见:获取用户Token 最小长度:1 最大长度:10000 |
| Content-Type | 是 | String | 该字段填为:application/json;charset=UTF-8。 最小长度:30 最大长度:30 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| host_group_name | 是 | String | 主机组名称不可重复,只支持输入英文、数字、中文、中划线、下划线及小数点,且不能以小数点、下划线开头或以小数点结尾 最小长度:1 最大长度:64 |
| host_group_type | 是 | String | 主机组类型。
|
| host_id_list | 否 | Array of strings | 主机组ID列表。主机类型必须与主机组类型一致. 当主机组接入类型是IP时,才可添加此字段。 最小长度:36 最大长度:36 |
| host_group_tag | 否 | Array of HostGroupTag objects | 标签信息。最多支持20个标签。 |
| agent_access_type | 否 | String | 主机接入类型
|
| labels | 否 | Array of strings | 主机组自定义标识,若主机接入类型为LABEL,此字段保存主机组的标识。
|
响应参数
状态码:200
| 参数 | 参数类型 | 描述 |
|---|---|---|
| host_group_id | String | 主机组ID |
| host_group_name | String | 主机组名称 |
| host_group_type | String | 主机组类型。
|
| host_id_list | Array of strings | 主机ID列表 |
| host_group_tag | Array of HostGroupTagResBody objects | 标签信息. |
| create_time | Long | 创建时间 |
| update_time | Long | 更新时间 |
| labels | Array of strings | 主机组标识 |
| agent_access_type | String | 主机接入类型 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| key | String | 标签Key |
| value | String | 标签Value |
| tags_to_streams_enable | Boolean | 是否将此标签应用至日志流上(只有日志组的标签可以将自身标签直接应用至日志流) |
状态码:400
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 错误码 |
| error_msg | String | 错误描述 |
状态码:500
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 错误码 |
| error_msg | String | 错误描述 |
请求示例
创建主机组,host_group_name和host_group_type为必填参数
POST https://{endpoint}/v3/{project_id}/lts/host-group
{
"agent_access_type" : "IP",
"create_time" : 1749782743454,
"host_group_id" : "204f02a9-5956-4d05-b80f-7657e6bbf8e0",
"host_group_name" : "test-api6",
"host_group_tag" : [ {
"key" : "1",
"tags_to_streams_enable" : true,
"value" : "1"
} ],
"host_group_type" : "linux",
"host_id_list" : [ "2b0d2d32-3db6-470b-8559-df24e1f659a1", "8a2a1b3e-8739-4d77-aecc-6b54e32209c1" ],
"labels" : [ ],
"update_time" : 1749782743454
} 响应示例
状态码:200
创建主机组请求响应成功
{
"host_group_id" : "598c77aa-c69b-42f0-8cb8-983178ad5b38",
"host_group_name" : "APIxx3",
"host_group_type" : "linux",
"host_id_list" : [ "dc1dab7e-b045-4e77-bda4-914d083d1bf7" ],
"host_group_tag" : [ {
"key" : "xxx",
"value" : "xxx",
"tags_to_streams_enable" : true
} ],
"create_time" : 1635149410332,
"update_time" : 1635149410332
} 状态码:400
非法请求 建议根据error_msg直接修改该请求。
{
"error_code" : "LTS.1812",
"error_msg" : "Invalid host group id"
} 状态码:500
表明服务端能被请求访问到,但是服务内部出错。
{
"error_code" : "LTS.0010",
"error_msg" : "Internal Server Error"
} 状态码
| 状态码 | 描述 |
|---|---|
| 200 | 创建主机组请求响应成功 |
| 400 | 非法请求 建议根据error_msg直接修改该请求。 |
| 500 | 表明服务端能被请求访问到,但是服务内部出错。 |
错误码
请参见错误码。