Creates a machine group by using the SLS CLI.
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
Required and command-specific parameters for create_machine_group:
|
Parameter |
Type |
Required |
Example |
Description |
|
--project_name |
String |
Yes |
aliyun-test-project |
Project name. |
|
--group_detail |
JSON Object |
Yes |
file://./machinegroup.json |
Path to the machine group configuration file. |
For information about SLS CLI global parameters, see Global parameters.
Examples
-
Create a file named machinegroup.json. The following example sets the machine group name to group_name2:
{ "machine_list": [ "machine1", "machine2" ], "machine_type": "userdefined", "group_name": "group_name2", "group_type": "", "group_attribute": { "groupTopic": "topic x" } }Parameters:
Parameter
Description
machine_list
Server identifiers in the machine group.
-
If machineIdentifyType is ip, enter server IP addresses.
-
If machineIdentifyType is userdefined, enter custom IDs. Create a custom ID-based machine group.
machine_type
Machine group identifier type. Valid values:
-
ip: IP address identifiers.
-
userdefined: Custom ID identifiers.
group_name
Machine group name. Requirements:
-
Must be unique within the project.
-
Contains only lowercase letters, digits, hyphens (-), and underscores (_).
-
Starts and ends with a lowercase letter or digit.
-
3 to 128 characters long.
group_type
Machine group type. Set to null.
group_attribute
Machine group attributes, described in the following table.
group_attribute parameters:
Parameter
Description
groupTopic
Machine group topic.
-
-
Create machine group group_name2 with the default account:
aliyunlog log create_machine_group --project_name="aliyun-test-project" --group_detail="file://./machinegroup.json"This command returns no output.
-
Verify the machine group:
aliyunlog log get_machine_group --project_name="aliyun-test-project" --group_name="group_name2"Sample output:
{ "createTime": 1622104319, "groupAttribute": { "externalName": "", "groupTopic": "topic x", "osType": "", "policy": "", "region": "" }, "groupName": "group_name2", "groupType": "", "lastModifyTime": 1622104319, "machineIdentifyType": "userdefined", "machineList": [ "machine1", "machine2" ] }
Error codes
If an error is returned, troubleshoot based on error codes of the related API operation. For more information, see Error codes.