This topic provides the DDL syntax that is used to create a Log Service result table, describes the parameters in the WITH clause, and provides data type mappings and references.

What is Log Service?

Log Service is an end-to-end logging service. Log Service allows you to collect, consume, ship, query, and analyze log data in a quick manner. It improves the operations and maintenance (O&M) efficiency and provides the capability to process large amounts of log data. Log Service is used to store streaming data. This way, Flink can use the streaming data that is stored in Log Service as output data.

Prerequisites

A project and a Logstore of Log Service are created. For more information, see Step 2: Create a project and a Logstore.

Limits

Only Flink that uses Ververica Runtime (VVR) 2.0.0 or later supports the Log Service connector.

DDL syntax

create table sls_sink(
 name varchar,
 age int,
 birthday int
)with(
 'connector'='sls',
 'endPoint'='<endPoint>',
 'accessId'='<yourAccessId>',
 'accessKey'='<yourAccessKey>',
 'project'='<yourProjectName>',
 'logstore'='<yourLogstoreName>'
);

Parameters in the WITH clause

Parameter Description Required Remarks
connector The type of the result table. Yes Set the value to sls.
endPoint The endpoint of Log Service. Yes For more information, see Endpoints.
project The name of a project. Yes N/A.
logstore The name of the table. Yes N/A.
accessId The AccessKey ID of your Alibaba Cloud account. Yes N/A.
accessKey The AccessKey secret of your Alibaba Cloud account. Yes N/A.
topicField Specifies a field name. The value of this parameter overwrites the value of the __topic__ attribute field to indicate the topic of the log. No The value of this parameter must be an existing field in the table. This parameter is empty by default.
timeField Specifies a field name. The value of this parameter overwrites the value of the __timestamp__ attribute field to indicate a log write event. No The value of this parameter must be an existing field of the INT type in the table. If no field is specified, the current time is used by default.
sourceField Specifies a field name. The value of this parameter overwrites the value of the __source__ attribute field to indicate the origin of the log. For example, the value is the IP address of the machine that generates the log. No The value of this parameter must be an existing field in the table. This parameter is empty by default.
flushIntervalMs The interval at which data writing is triggered. No Default value: 2000. Unit: milliseconds.

Data type mappings

The following table lists the data type mappings between Log Service and Flink fields. We recommend that you declare the mappings in a DDL statement.

Data type of Log Service Data type of Flink
STRING VARCHAR