ALIYUN::SLS::ConsumerGroup

ALIYUN::SLS::ConsumerGroup类型用于在指定的Logstore上创建一个消费组。

语法

{
  "Type": "ALIYUN::SLS::ConsumerGroup",
  "Properties": {
    "ConsumerGroup": String,
    "Logstore": String,
    "Order": Boolean,
    "Project": String,
    "Timeout": Integer
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

ConsumerGroup

String

消费组名称。

在 Project 下必须唯一。

Logstore

String

Logstore 名称。

Order

Boolean

是否按顺序消费。

取值:

  • true:按顺序消费。

    • 同一个 Shard 内按照保留字段**__tag__:__receive_time__**由小到大按顺序消费。

    • Shard 分裂后,先消费原 Shard 数据,然后同时消费由该 Shard 分裂的 Shard 数据。

    • Shard 合并后,先消费原 Shard 数据,然后消费由原 Shard 合并后的新 Shard 数据。

  • false:不按顺序消费。即所有 Shard 同时开始消费,Shard 分裂或者合并后产生的新 Shard,也会立即消费。

Project

String

Project 名称。

Timeout

Integer

超时时间。

在超时时间段内没有收到心跳,消费者将被删除。单位:秒。

返回值

Fn::GetAtt

  • Project:Project 名称。

  • Logstore:Logstore 名称。

  • ConsumerGroup:消费组名称。

示例

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  Order:
    Type: Boolean
    Description:
      en: |-
        Specifies whether to consume data in sequence. Valid values:
        true
        In a shard, data is consumed in ascending order based on the value of the **__tag__:__receive_time__** field.
        If a shard is split, data in the original shard is consumed first. Then, data in the new shards is consumed at the same time.
        If shards are merged, data in the original shards is consumed first. Then, data in the new shard is consumed.
        false Data in all shards is consumed at the same time. If a new shard is generated after a shard is split or after shards are merged, data in the new shard is immediately consumed.
    Required: true
  Project:
    Type: String
    Description:
      en: The name of the project.
    Required: true
  Logstore:
    Type: String
    Description:
      en: The name of the Logstore.
    Required: true
  Timeout:
    Type: Number
    Description:
      en: 'The timeout period. If the server does not receive heartbeats from a consumer within the timeout period, the server deletes the consumer. Unit: seconds.'
    Required: true
    MinValue: 1
    MaxValue: 4294967295
  ConsumerGroup:
    Type: String
    Description:
      en: The name of the consumer group. The name must be unique in a project.
    Required: true
Resources:
  SLSConsumerGroup:
    Type: ALIYUN::SLS::ConsumerGroup
    Properties:
      Order:
        Ref: Order
      Project:
        Ref: Project
      Logstore:
        Ref: Logstore
      Timeout:
        Ref: Timeout
      ConsumerGroup:
        Ref: ConsumerGroup
Outputs:
  Project:
    Description: The name of the project to which the logstore belongs.
    Value:
      Fn::GetAtt:
        - SLSConsumerGroup
        - Project
  Logstore:
    Description: The name of the logstore to which this consumer group belongs.
    Value:
      Fn::GetAtt:
        - SLSConsumerGroup
        - Logstore
  ConsumerGroup:
    Description: The name of the consumer group.
    Value:
      Fn::GetAtt:
        - SLSConsumerGroup
        - ConsumerGroup
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "Order": {
      "Type": "Boolean",
      "Description": {
        "en": "Specifies whether to consume data in sequence. Valid values:\ntrue\nIn a shard, data is consumed in ascending order based on the value of the **__tag__:__receive_time__** field.\nIf a shard is split, data in the original shard is consumed first. Then, data in the new shards is consumed at the same time.\nIf shards are merged, data in the original shards is consumed first. Then, data in the new shard is consumed.\nfalse Data in all shards is consumed at the same time. If a new shard is generated after a shard is split or after shards are merged, data in the new shard is immediately consumed."
      },
      "Required": true
    },
    "Project": {
      "Type": "String",
      "Description": {
        "en": "The name of the project."
      },
      "Required": true
    },
    "Logstore": {
      "Type": "String",
      "Description": {
        "en": "The name of the Logstore."
      },
      "Required": true
    },
    "Timeout": {
      "Type": "Number",
      "Description": {
        "en": "The timeout period. If the server does not receive heartbeats from a consumer within the timeout period, the server deletes the consumer. Unit: seconds."
      },
      "Required": true,
      "MinValue": 1,
      "MaxValue": 4294967295
    },
    "ConsumerGroup": {
      "Type": "String",
      "Description": {
        "en": "The name of the consumer group. The name must be unique in a project."
      },
      "Required": true
    }
  },
  "Resources": {
    "SLSConsumerGroup": {
      "Type": "ALIYUN::SLS::ConsumerGroup",
      "Properties": {
        "Order": {
          "Ref": "Order"
        },
        "Project": {
          "Ref": "Project"
        },
        "Logstore": {
          "Ref": "Logstore"
        },
        "Timeout": {
          "Ref": "Timeout"
        },
        "ConsumerGroup": {
          "Ref": "ConsumerGroup"
        }
      }
    }
  },
  "Outputs": {
    "Project": {
      "Description": "The name of the project to which the logstore belongs.",
      "Value": {
        "Fn::GetAtt": [
          "SLSConsumerGroup",
          "Project"
        ]
      }
    },
    "Logstore": {
      "Description": "The name of the logstore to which this consumer group belongs.",
      "Value": {
        "Fn::GetAtt": [
          "SLSConsumerGroup",
          "Logstore"
        ]
      }
    },
    "ConsumerGroup": {
      "Description": "The name of the consumer group.",
      "Value": {
        "Fn::GetAtt": [
          "SLSConsumerGroup",
          "ConsumerGroup"
        ]
      }
    }
  }
}