调用CreateConsumerGroup接口在指定的Logstore上创建一个消费组。
接口说明
- 请求语法中Host由Project名称和日志服务Endpoint构成,您需要在Host中指定Project。
- 每个Logstore中最多创建30个消费组。
- 日志服务提供基于Java SDK的普通消费和消费组消费日志使用示例。更多信息,请参见普通消费和通过消费组消费日志数据。
请求头
该接口使用公共请求头,无特殊请求头。请参见公共请求参数文档。
请求语法
POST /logstores/{logstore}/consumergroups HTTP/1.1
请求参数
名称 | 类型 | 位置 | 是否必选 | 示例值 | 描述 |
---|---|---|---|---|---|
logstore | String | Path | 是 | aliyun-test-logstore |
Logstore名称。 |
project | String | Host | 是 | aliyun-test-project |
Project名称。 |
Object | Body | 是 |
请求体参数。 |
||
consumerGroup | String | Body | 是 | consumerGroupX |
消费组名称,在Project下必须唯一。 |
timeout | Integer | Body | 是 | 300 |
超时时间。在超时时间段内没有收到心跳,消费者将被删除。单位:秒。 |
order | Boolean | Body | 是 | true |
是否按顺序消费。
|
返回数据
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
Server | String | nginx |
服务器名称。 |
Content-Type | String | application/json |
返回的响应体的内容格式。 |
Content-Length | String | 0 |
响应内容长度。 |
Connection | String | close |
是否长链接。取值包括:
|
Date | String | Sun, 27 May 2018 08:25:04 GMT |
当前返回响应的时间。 |
x-log-requestid | String | 5B0A6B60BB6EE39764D458B5 |
服务端产生的标识,该请求的唯一ID。 |
示例
请求示例
POST /logstores/aliyun-test-logstore/consumergroups HTTP/1.1
Host:ali-test-project.cn-hangzhou.log.aliyuncs.com
Content-Type:application/json
{
"consumerGroup" : "consumerGroupX",
"timeout" : 300,
"order" : true
}
正常返回示例
JSON
格式
HTTP/1.1 200 OK
错误码
访问错误中心查看更多错误码。
HttpStatusCode |
ErrorCode |
ErrorMessage |
错误码描述 |
---|---|---|---|
404 |
ProjectNotExist |
Project does not exist. |
Project不存在。 |
404 |
LogStoreNotExist |
Logstore does not exist. |
Logstore不存在。 |
400 |
ConsumerGroupAlreadyExist |
consumer group already exist. |
消费组已存在。 |
400 |
JsonInfoInvalid |
consumerGroup or timeout is of error format. |
参数consumerGroup或timeout格式错误。 |
500 |
InternalServerError |
Specified Server Error Message. |
内部服务调用错误。 |
更多信息,请参见通用错误码。