Log Service (SLS)

更新时间:
复制 MD 格式

This topic describes how to add Log Service (SLS) as a data provider for an event stream in the EventBridge console.

Prerequisites

Background

Log Service (SLS) is a cloud-native observability and analytics platform that offers a large-scale, low-cost, real-time service for processing data such as logs, metrics, and traces. Log Service provides one-stop capabilities for data collection, processing, query and analysis, visualization, alerting, consumption, and delivery to enhance your R&D, O&M, operational, and security capabilities. EventBridge can obtain real-time events from SLS and load them to event targets. This helps you respond more efficiently to various business and operational events.

Procedure

  1. Log on to the EventBridge console. In the left-side navigation pane, click Event Streams.

  2. In the top navigation bar, select a region and click Create Event Stream.

  3. In the Create Event Stream panel, set Task Name and Description, configure the following parameters, and then click Save.

    • Task creation

      1. In the Source step, set Data Provider to Simple Log Service, configure the following parameters, and then click Next Step.

        Parameter

        Description

        Example

        Project

        Select the project that you created in Log Service (SLS).

        test-project

        Logstores

        Select the Logstore that you created in Log Service (SLS).

        test-Logstore

        Consumer Offset

        The position to start consuming events. You can select Earliest Offset, Latest Offset, or Specified Time (a Unix timestamp in seconds).

        Latest Offset

        Role

        The role that EventBridge uses to read log content from SLS. For information about the required permission policy, see Create a custom event source for Log Service (SLS).

        testRole

        Messages

        The maximum number of messages in each batch. A request is sent only when the number of accumulated messages reaches this value. The value must be an integer from 1 to 10,000.

        100

        Interval (Unit: Seconds)

        The interval at which to send aggregated message batches. The value must be an integer from 0 to 15. A value of 0 indicates no delay.

        3

      2. In the Filtering, Transformation, and Sink steps, configure the event filter, transformation rules, and event target. For information about how to configure event transformation, see Use Function Compute for data cleansing.

    • Task properties

      Configure the retry policy and dead-letter queue for the event stream. For more information, see Retry policies and dead-letter queues.

  4. Return to the Event Streams page. Find the event stream that you created, and in the Actions column, click Enable.

    It takes 30 to 60 seconds to enable the event stream. You can view the startup progress in the Status column on the Event Streams page.

Sample event

{
    "datacontenttype": "application/json;charset=utf-8",
    "aliyunaccountid": "175299981560****",
    "data": {
        "key1": "value1",
        "key2": "value2",
        "__topic__": "test_topic",
        "__source__": "test_source",
        "__client_ip__": "122.231.XX.XX",
        "__receive_time__": "1663487595",
        "__pack_id__": "59b662b2257796****"
    },
    "subject": "acs:log:cn-qingdao:175299981560****:project/qiingdaoproject/logstore/qingdao-logstore-1",
    "aliyunoriginalaccountid": "175299981560****",
    "source": "test-SLS",
    "type": "sls:connector",
    "aliyunpublishtime": "2022-09-18T07:53:15.387Z",
    "specversion": "1.0",
    "aliyuneventbusname": "qingdaoBus",
    "id": "qiingdaoproject-qingdao-logstore-1-1-MTY2MzExODM5ODY4NjAxOTQyMw****",
    "time": "2022-09-18T07:53:12Z",
    "aliyunregionid": "cn-qingdao",
    "aliyunpublishaddr": "10.50.XX.XX"
}

For an explanation of the parameters defined in the CloudEvents specification, see Event overview.

The following table describes the parameters in the data field. Parameters that start and end with __ are SLS system fields. For more information, see Reserved Fields.

Parameter

Type

Example value

Description

key1

String

testKey

A user-defined field and its value from the log, for example, "key1": "value1".

__topic__

String

testTopic

The log topic.

__source__

String

testSource

The log source.

__client_ip__

String

122.231.XX.XX

The IP address of the host that generated the log.

__receive_time__

String

1663487595

The time when the server received the log.

__pack_id__

String

59b662b2257796****

The unique ID of the LogGroup to which the log belongs.