All Products
Document Center

Log Service:create_machine_group

Last Updated:Oct 26, 2023

Creates a machine group.

Request syntax

aliyunlog log create_machine_group --project_name=<value> --group_detail=<value> [--access-id=<value>] [--access-key=<value>] [--sts-token=<value>] [--region-endpoint=<value>] [--client-name=<value>] [--jmes-filter=<value>] [--format-output=<value>] [--decode-output=<value>]

Request parameters

The following table describes the required and specific parameters of the create_machine_group command.
--project_nameStringYesaliyun-test-projectThe name of the project.
--group_detailJSON ObjectYesfile://./machinegroup.jsonThe path of the configuration file for the machine group.
For information about the global parameters of the Log Service command-line interface (CLI), see Global parameters.


  1. Create a file named machinegroup.json in which the machine group name is group_name2. The following example shows the content of the machinegroup.json file:
      "machine_list": [
      "machine_type": "userdefined",
      "group_name": "group_name2",
      "group_type": "",
      "group_attribute": {
        "groupTopic": "topic x"
    The following table describes the parameters.
    machine_listThe identifiers of the servers in the machine group.
    • If you set the machineIdentifyType parameter to ip, enter the IP addresses of the servers in the machine group.
    • If you set the machineIdentifyType parameter to userdefined, enter custom IDs. For more information about how to configure a custom ID, see Create a custom ID-based machine group.
    machine_typeThe type of the machine group identifier. Valid values:
    • ip: The machine group uses IP addresses as identifiers.
    • userdefined: The machine group uses custom IDs as identifiers.
    group_nameThe name of the machine group. The name must meet the following requirements:
    • The name must be unique in a project.
    • The name can contain only lowercase letters, digits, hyphens (-), and underscores (_).
    • The name must start and end with a lowercase letter or a digit.
    • The name must be 3 to 128 characters in length.
    group_typeThe type of the machine group. Valid values: null.
    group_attributeThe attribute of the machine group. For more information about the group_attribute parameter, see the following table.
    The following table describes the parameters in group_attribute.
    groupTopicThe topic of the machine group.
  2. Use the default account to create a machine group named group_name2.
    aliyunlog log create_machine_group --project_name="aliyun-test-project" --group_detail="file://./machinegroup.json"
    After you run the command, no responses are returned.
  3. Query the machine group that you created. Run the following command:
    aliyunlog log get_machine_group --project_name="aliyun-test-project" --group_name="group_name2"
    The following output is returned:
      "createTime": 1622104319,
      "groupAttribute": {
        "groupTopic": "topic x"
      "groupName": "group_name2",
      "groupType": "",
      "lastModifyTime": 1622104319,
      "machineIdentifyType": "userdefined",
      "machineList": [

Error codes

If an error message is returned, fix the error based on the error codes of the related API operation. For more information, see Error codes of CreateMachineGroup.

API reference