Query the machines in a machine group

Updated at:

Call the ListMachines operation to list the machines in a machine group that are connected to Simple Log Service.

Prerequisites

Parameters

def list_machines(self, project_name, group_name, offset=0, size=100):

Request parameters

Parameter

Type

Required

Description

project_name

String

Yes

The name of the project. The project in Simple Log Service is used to isolate the resources of different users and control access to specific resources. See Manage projects.

group_name

String

Yes

The name of the machine group.

offset

int

No

The line from which the query starts. Default value: 0.

size

int

No

The number of entries per page. Default value: 100. Maximum: 500.

Response parameters

For more information about the response parameters, see ListMachines.

Sample code

from aliyun.log import LogClient
import os

# In this example, the AccessKey ID and AccessKey secret are obtained from environment variables.
access_key_id = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID', '')
access_key_secret = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET', '')

# The Simple Log Service endpoint.
endpoint = "cn-hangzhou.log.aliyuncs.com"

client = LogClient(endpoint, access_key_id, access_key_secret)

project_name = "proj-test-1"
group_name = "group-1"


def main():
    # Query a list of machines that are connected to Simple Log Service in a machine group.
    res = client.list_machines(project_name, group_name)
    res.log_print()


if __name__ == '__main__':
    main()

 

Sample response

GetMachineGroupResponse:
headers: {'Server': 'AliyunSLS', 'Content-Type': 'application/json', 'Content-Length': '195', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Mon, 17 Mar 2025 03:16:49 GMT', 'x-log-time': '1742181409', 'x-log-requestid': '67D794214C25EA********8BD'}
machine_count 1
machine_total 1
machines:
MachineStatus: machine_unique_id=B0***A5A-FB31-11EF-8A47-00********2A, user_defined_id=, heartbeat_time=174***1399

Process finished with exit code 0

References