Query the information about a machine group

Updated at:

Call the GetMachineGroup operation to query the details of a machine group.

Prerequisites

Parameters

def get_machine_group(self, project_name, group_name):

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.

Response parameters

For more information about the response parameters, see machineGroup.

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"

# Create an instance of the LogClient class.
client = LogClient(endpoint, access_key_id, access_key_secret)

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


def main():
    # Query the information about a machine group.
    res = client.get_machine_group(project_name, group_name)
    res.log_print()


if __name__ == '__main__':
    main()

Sample response

GetMachineGroupResponse:
headers: {'Server': 'AliyunSLS', 'Content-Type': 'application/json', 'Content-Length': '220', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Tue, 15 Oct 2024 05:44:43 GMT', 'x-log-time': '1728971083', 'x-log-requestid': '670E014B5EE8E6F9793A****'}
machine_group {'groupName': 'group-1', 'groupType': '', 'groupAttribute': {'externalName': '', 'groupTopic': '', 'osType': '', 'region': '', 'policy': ''}, 'machineIdentifyType': 'ip', 'machineList': ['172.16.0.1']}

Process finished with exit code 0

References