Update a machine group

Updated at:

Call the UpdateMachineGroup operation to update the configuration of a machine group.

Prerequisites

Parameters

def update_machine_group(self, project_name, group_detail):

Request parameters

Parameter

Type

Required

Description

project_name

String

Yes

The name of the project. Projects in Simple Log Service isolate resources and control access across users. For more information, see Manage projects.

group_detail

MachineGroupDetail

Yes

The configuration of a machine group.

Parameters of MachineGroupDetail

Parameter

Type

Required

Description

group_name

String

Yes

The name of the machine group. The name must meet the following requirements:

  • The name can contain only lowercase letters, digits, hyphens (-), and underscores (_).

  • The name must start and end with a lowercase letter or digit.

  • The name must be 2 to 128 characters in length.

machine_type

String

Yes

The identifier of the machine group. Valid values:

  • ip: The machine group uses IP addresses as identifiers.

  • userdefined: The machine group uses custom identifiers.

machine_list

List

Yes

The machine groups.

  • If you set machine_type to ip, enter the server IP addresses that are automatically obtained by Logtail. For more information, see Manage machine groups.

  • If you set machine_type to userdefined, enter the custom identifiers of the machine groups. For more information, see Manage machine groups.

Response parameters

For more information about the response parameters, see UpdateMachineGroup.

Sample code

from aliyun.log import LogClient, MachineGroupDetail
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():
    group_name = "group-1"
    machine_type = "ip"
    machine_list = ['192.168.0.10', '192.168.0.30']
    # Create an instance of the MachineGroupDetail class.
    group_detail = MachineGroupDetail(group_name, machine_type, machine_list)
    # Update a machine group.
    res = client.update_machine_group(project_name, group_detail)
    res.log_print()


if __name__ == '__main__':
    main()
    

Sample response

CreateIndexResponse:
headers: {'Server': 'AliyunSLS', 'Content-Length': '0', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Sat, 12 Oct 2024 06:27:20 GMT', 'x-log-time': '1728714440', 'x-log-requestid': '670A16C88F14B9A316BC****'}

Process finished with exit code 0

References