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

Querying Hosts

Function

Query a host list.

URI

POST /v3/{project_id}/lts/host-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=UTF-8.

Default: None

Minimum: 30

Maximum: 30

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

host_id_list

No

Array of strings

Host ID list. You can filter hosts by host ID.

Minimum: 36

Maximum: 36

Array Length: 0 - 100

filter

No

GetHostListFilter object

Filters other than host IDs.

Table 4 GetHostListFilter

Parameter

Mandatory

Type

Description

host_name_list

No

Array of strings

Host name list. You can filter hosts by host name.

Minimum: 1

Maximum: 128

Array Length: 0 - 100

host_ip_list

No

Array of strings

Host ID list. You can filter hosts by host IP address.

Minimum: 1

Maximum: 16

Array Length: 0 - 100

host_status

No

String

Host status. You can filter hosts by host status. uninstall: The host is not installed. running: The host is running. offline: The host is offline. error: The host is abnormal. plugin error: invalid plug-in. installing: The host is being installed. install-fail: The installation fails. upgrading: The upgrade is in progress. upgrading-transient: The upgrade is in progress. upgrade failed: The upgrade fails. upgrade-fail: The upgrade fails. uninstalling: The host is being uninstalled. uninstalling-transient: The host is being uninstalled. authentication error: The authentication fails.

Enumeration values:

  • uninstall

  • running

  • offline

  • error

  • plugin error

  • installing

  • install-fail

  • upgrading

  • upgrading-transient

  • upgrade failed

  • upgrade-fail

  • uninstalling

  • uninstalling-transient

  • authentication error

host_version

No

String

Host version. You can filter hosts by host version.

Minimum: 1

Maximum: 16

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

result

Array of GetHostListInfo objects

Host list.

Array Length: 0 - 1000

total

Long

Total number of hosts.

Minimum: 0

Maximum: 10000

Table 6 GetHostListInfo

Parameter

Type

Description

host_id

String

Host ID.

Minimum: 36

Maximum: 36

host_ip

String

Host IP address.

Minimum: 1

Maximum: 16

host_name

String

Host name.

Minimum: 1

Maximum: 128

host_status

String

Host status. uninstall: not installed. running: The job is running. offline: The host is offline. error: The host is abnormal. plugin error: invalid plug-in. installing: The host is being installed. install-fail: The installation fails. upgrading: The upgrade is in progress. upgrading-transient: The upgrade is in progress. upgrade failed: The upgrade fails. upgrade-fail: The upgrade fails. uninstalling: The host is being uninstalled. uninstalling-transient: The host is being uninstalled. authentication error: The authentication fails.

Enumeration values:

  • uninstall

  • running

  • offline

  • error

  • plugin error

  • installing

  • install-fail

  • upgrading

  • upgrading-transient

  • upgrade failed

  • upgrade-fail

  • uninstalling

  • uninstalling-transient

  • authentication error

host_type

String

Host type. The value can be linux.

Enumeration values:

  • linux

host_version

String

Host version.

Minimum: 1

Maximum: 16

update_time

Long

Update time.

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 500

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Requests

Hosts 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}/v2/{project_id}/lts/host-list

/v3/{project_id}/lts/host-list 
{
    "host_id_list" : ["713a9f81-574b-45aa-92df-24c4caxxxxxx", "c7085aa9-2142-4ada-9f78-bf81ffxxxxxx"],
    "filter" : {
        "host_name_list" : ["ecs-xxxx", "10.66.16xxx"],
        "host_ip_list" : ["192.168xxxx"],
        "host_status" : "ruxxxx",
        "host_version" : "5.13.xxxx"
    }
}

Example Responses

Status code: 200

The host query is successful.

{
  "result" : [ {
    "host_id" : "dc1dab7e-b045-4e77-bda4-914xxxxxx",
    "host_ip" : "172.16.xxxx",
    "host_name" : "ecs-apmtexxxxxx",
    "host_status" : "xxxxxx",
    "host_type" : "xxxxx",
    "host_version" : "5.13.xx.x",
    "update_time" : 1637223314526
  } ],
  "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 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 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.