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.
Parameter Type Required Example Description
--project_name String Yes aliyun-test-project The name of the project.
--group_detail JSON Object Yes file://./machinegroup.json The 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 variables.

Examples

  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": [
        "machine1",
        "machine2"
      ],
      "machine_type": "userdefined",
      "group_name": "group_name2",
      "group_type": "",
      "group_attribute": {
        "externalName": "ex name",
        "groupTopic": "topic x"
      }
    }
    The following table describes the parameters.
    Parameter Description
    machine_list The 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_type The 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_name The 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_type The type of the machine group. Valid values: null.
    group_attribute The 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.
    Parameter Description
    externalName The external management identifier on which the machine group depends.
    groupTopic The 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": {
        "externalName": "ex name",
        "groupTopic": "topic x"
      },
      "groupName": "group_name2",
      "groupType": "",
      "lastModifyTime": 1622104319,
      "machineIdentifyType": "userdefined",
      "machineList": [
        "machine1",
        "machine2"
      ]
    }

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

CreateMachineGroup