Updated on 2024-04-12 GMT+08:00

Querying Host Groups

Function

Query the list of host groups.

URI

POST /v3/{project_id}/lts/host-group-list

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain a project ID, see Obtaining the Account Tenant ID, Log Group ID, and Log Stream ID.

Default: None

Minimum: 32

Maximum: 32

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token obtained from IAM.

Default: None

Minimum: 1000

Maximum: 2000

Content-Type

Yes

String

Set this parameter to application/json;charset=utf8.

Default: None

Minimum: 29

Maximum: 29

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

host_group_id_list

No

Array of strings

Host group ID.

Minimum: 36

Maximum: 36

Array Length: 0 - 1000

filter

No

GetHostGroupListFilter object

Host group filters.

Table 4 GetHostGroupListFilter

Parameter

Mandatory

Type

Description

host_group_type

No

String

Host type. The value can be linux.

Enumeration values:

  • linux

host_group_name_list

No

Array of strings

List of host group names.

Minimum: 1

Maximum: 64

Array Length: 0 - 1000

host_name_list

No

Array of strings

Host name list.

Minimum: 1

Maximum: 128

Array Length: 0 - 1000

host_group_tag

No

GetHostGroupListTag object

Host group tags.

Table 5 GetHostGroupListTag

Parameter

Mandatory

Type

Description

tag_type

No

String

Tag type. Tag filtering logic: AND or OR.

Enumeration values:

  • AND

  • OR

tag_list

No

Array of HostGroupTag objects

Host group tags.

Array Length: 1 - 1000

Table 6 HostGroupTag

Parameter

Mandatory

Type

Description

key

No

String

Tag key.

Minimum: 1

Maximum: 36

value

No

String

Tag value.

Minimum: 1

Maximum: 36

Response Parameters

Status code: 200

Table 7 Response body parameters

Parameter

Type

Description

result

Array of GetHostGroupInfo objects

Host group list.

Array Length: 0 - 1000

total

Long

Total number of host groups.

Minimum: 0

Maximum: 1000

Table 8 GetHostGroupInfo

Parameter

Type

Description

host_group_id

String

Host group ID.

Minimum: 36

Maximum: 36

host_group_name

String

Host group name.

Minimum: 1

Maximum: 64

host_group_type

String

Host type. The value can be linux.

Enumeration values:

  • linux

host_id_list

Array of strings

Host ID list.

Minimum: 36

Maximum: 36

Array Length: 0 - 1000

host_group_tag

Array of HostGroupTag objects

Tags.

Array Length: 0 - 1000

create_time

Long

Creation time.

Minimum: 0

Maximum: 9999999999999

update_time

Long

Update time.

Minimum: 0

Maximum: 9999999999999

agent_access_type

String

Host group type.

Enumeration values:

  • LABEL

  • IP

labels

Array of strings

Tag.

Table 9 HostGroupTag

Parameter

Type

Description

key

String

Tag key.

Minimum: 1

Maximum: 36

value

String

Tag value.

Minimum: 1

Maximum: 36

Status code: 400

Table 10 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum: 8

Maximum: 8

error_msg

String

Error message.

Minimum: 1

Maximum: 1000

Status code: 500

Table 11 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum: 8

Maximum: 8

error_msg

String

Error message.

Minimum: 1

Maximum: 1000

Example Requests

Host groups are sorted by filters specified in the request body. If no filters are configured in the body, all host groups are queried.

POST https://{endpoint}/v3/{project_id}/lts/host-group-list

/v3/{project_id}/lts/host-group-list 
{
    "host_group_id_list" : ["bca6d903-3528-42a8-91f4-586722cxxxxx"],
    "filter" : {
        "host_group_type" : "lixxx",
        "host_group_name_list" : ["wjyTxxx", "xxxest"],
        "host_name_list":["ecs-apmtexxxdeletion"],
        "host_group_tag" : {
            "tag_type" : "AND",
            "tag_list" : [{
                    "key" : "xxx",
                    "value" : "xxx"
                }
            ]
        }
    }
}

Example Responses

Status code: 200

The host group query is successful.

{
  "result" : [ {
    "agent_access_type" : "IP",
    "create_time" : 1684811693411,
    "host_group_id" : "xxxx-3edb-4bb9-ba61-6b690d44d1cd",
    "host_group_name" : "lmy-xxxx-0522-3",
    "host_group_tag" : [ {
      "key" : "test001",
      "value" : "bbb1"
    }, {
      "key" : "aaa2",
      "value" : "bbb2"
    } ],
    "host_group_type" : "linux",
    "host_id_list" : [ "xxxxx-3054-4f4a-a0b3-86c804d31841" ],
    "labels" : [ ],
    "update_time" : 1684811693411
  } ],
  "total" : 1
}

Status code: 400

Invalid request. Modify the request based on the description in error_msg before a retry.

{
  "error_code" : "LTS.1807",
  "error_msg" : "Invalid host group id"
}

Status code: 500

The server has received the request but encountered an internal error.

{
  "error_code" : "LTS.0010",
  "error_msg" : "The system encountered an internal error"
}

Status Codes

Status Code

Description

200

The host group query is successful.

400

Invalid request. Modify the request based on the description in error_msg before a retry.

500

The server has received the request but encountered an internal error.

Error Codes

See Error Codes.