You can call this operation to create a consumer group and consume data from a specified Logstore.

Example:
POST /logstores/{logstoreName}/consumergroups

Request syntax

POST /logstores/<logstoreName>/consumergroups HTTP/1.1
Authorization: <AuthorizationString>
x-log-bodyrawsize: 0
User-Agent: <UserAgent>
x-log-apiversion: 0.6.0
Host: <Project Endpoint>
x-log-signaturemethod: hmac-sha1
Date: <GMT Date>
Content-Type: application/json
Content-MD5: F58544E4D022CC28A93D0B7CC208A5AA
Content-Length: <ContentLength>
{
  "consumerGroup": <consumerGroup>,
  "timeout": <timeout>,
  "order": <order>
}

Request parameters

Parameter Type Required Description
logstoreName string Yes The name of the Logstore that the specified consumer group reads data from.
consumerGroup string Yes The name of the consumer group that you want to create. Each consumer group must be unique for a project.
timeout integer Yes The timeout. If the specified Logstore does not receive a heartbeat message from a consumer within the timeout period, the consumer is deleted.
order bool Yes Specifies whether to consume data in sequence of a single shard. Valid values: true and false.
  • true: specifies that the data in a single shard is consumed in sequence. After the shard is split, the data in the original shard is consumed first, and then the data in both child shards is consumed simultaneously.
  • false: specifies that the data in a single shard is consumed randomly.
Request header

The CreateConsumerGroup API operation does not have any special request header. For more information about the common request headers of Log Service API operations, see Public request header.

Response header

The CreateConsumerGroup API operation does not have any special response header. For more information about the common response headers of Log Service API operations, see Public response header.

Response elements

HTTP status code 200 is returned.

Error codes

In addition to the Common error codes of Log Service API operations, the API operation may also return the following special error codes.

HTTP status code Error code Error message
400 ConsumerGroupAlreadyExist consumer group already exist
400 JsonInfoInvalid consumerGroup or timeout is of error format
404 ProjectNotExist The Project does not exist : {Project}
404 LogStoreNotExist logstore {logstoreName} does not exist
500 InternalServerError Specified Server Error Message

Examples

Sample requests
POST /logstores/my-logstore/consumergroups HTTP/1.1
Header:
Authorization: LOG <yourAccessKeyId>:<yourSignature>
x-log-bodyrawsize: 0
User-Agent: sls-java-sdk-v-0.6.1
x-log-apiversion: 0.6.0
Host: my-project.cn-shanghai.log.aliyuncs.com
x-log-signaturemethod: hmac-sha1
Date: Fri, 04 May 2018 08:02:22 GMT
Content-Type: application/json
Content-MD5: F58544E4D022CC28A93D0B7CC208A5AA
Content-Length: 65
Connection: Keep-Alive
Body:
{
  "consumerGroup": "consumer-group-1",
  "timeout": 300,
  "order": true
}
Sample responses
HTTP/1.1 200
Server: nginx/1.12.1
Content-Length: 0
Connection: close
Access-Control-Allow-Origin: *
Date: Fri, 04 May 2018 08:15:11 GMT
x-log-requestid: 5AEC168FA796F4195BF404CB