Creates a machine group. A machine group consists of multiple servers from which you can use Logtail to collect logs,and it can manage these servers.

Request syntax

POST /machinegroups HTTP/1.1
Authorization: <AuthorizationString> 
Content-Type:application/json
Content-Length:<Content Length>
Content-MD5<:<Content MD5>
Date: <GMT Date>
Host: <Project Endpoint>
x-log-apiversion: 0.6.0
x-log-signaturemethod: hmac-sha1
{
    "groupName" : "testgroup",
    "groupType" : "",
    "groupAttribute" : {
        "externalName" : "testgroup",
        "groupTopic": "testgrouptopic"
    },
    "machineIdentifyType" : "ip",
    "machineList" : [
        "test-ip1",
        "test-ip2"
    ]
}

Request elements

  • Request headers

    The CreateMachineGroup API operation does not have operation-specific request headers. For information about the common request headers of Log Service API operations, see Common request headers.

  • Parameters
    Parameter Type Required Example Description
    groupName string Yes test-machine-group The name of the machine group. The name must be unique in a project.
    groupType string No None. The type of the machine group. Default value: null.
    machineIdentifyType string Yes ip The type of the machine group identifier. Valid values: ip and userdefined.
    groupAttribute object Yes None. The attribute of the machine group. Default value: null.
    machineList array Yes 127.0.0.1 The list of machine identifiers, which can be IP addresses or user-defined identifiers.

    The groupAttribute parameter consists of the following parameters.

    Parameter Type Required Example Description
    groupTopic string No testtopic The topic of the machine group. Default value: null.
    externalName string No testgroup The external management identifier on which the machine group depends. Default value: null.

Response elements

  • Response headers

    The CreateMachineGroup API operation does not have operation-specific response headers. For information about common response headers of Log Service API operations, see Common response headers.

  • Response parameters

    The HTTP status code 200 is returned.

Examples

  • Sample requests
    POST /machinegroups HTTP/1.1
    Header :
    {
        "x-log-apiversion": "0.6.0",
        "Authorization": "LOG <yourAccessKeyId>:<yourSignature>",
        "Host": "ali-test-project.cn-hangzhou-devcommon-intranet.sls.aliyuncs.com",
        "Date": "Tue, 10 Nov 2015 17:57:33 GMT",
        "Content-Length": "187",
        "x-log-signaturemethod": "hmac-sha1",
        "Content-MD5": "82033D507DEAAD72067BB58DFDCB590D",
        "User-Agent": "sls-java-sdk-v-0.6.0",
        "Content-Type": "application/json",
        "x-log-bodyrawsize": "0"
    }
    Body :
    {
        "groupName": "test-machine-group",
        "groupType": "",
        "machineIdentifyType": "ip",
        "groupAttribute":     {
            "groupTopic": "testtopic",
            "externalName": "testgroup"
        },
        "machineList":     [
            "127.0.0.1",
            "127.0.0.2"
        ]
    }
  • Sample success responses
    HTTP/1.1 200 OK
    Header :
    {
        "Date": "Tue, 10 Nov 2015 17:57:33 GMT",
        "Content-Length": "0",
        "x-log-requestid": "5642300D99248CB76D005D36",
        "Connection": "close",
        "Server": "nginx/1.6.1"
    }

Error codes

HTTP status code Error code Error message Description
400 MachineGroupAlreadyExist group {GroupName} already exists The error message returned because the machine group already exists.
400 InvalidParameter invalid group resource json The error message returned because a parameter value is invalid.
500 InternalServerError Internal server error The error message returned because an internal server error has occurred.

For more information about the error codes, see Common error codes.