This topic describes how to run a Flink DataStream job to read data from Alibaba Cloud Log Service.
Prerequisites
- Java Development Kit (JDK) 8 is installed on your machine.
- Maven 3.X is installed on your machine.
- An integrated development environment (IDE) for Java or Scala is installed on your machine. We recommend that you use IntelliJ IDEA. The JDK and Maven are configured.
- A Logstore is created in Log Service, and test data exists in the Logstore.
Background information
Notice Only Blink 3.X supports this demo.
Develop a job
Publish a job
For more information about how to publish a job, see Publish a job.
The following example shows the job content:
Note Before you publish the job, set the Parallelism parameter for the source table on
the Configurations tab of the Development page. The parallelism setting of the source table cannot be greater than the number
of shards in the source table. Otherwise, a JobManager error occurs when the job starts.
-- Required. The full name of the main class.
--blink.main.class=com.aliyun.openservices.log.flink.ConsumerSample
-- The name of the job.
blink.job.name=sls
-- The resource name of the JAR package that contains the full name of the main class. If multiple JAR packages exist, you must specify this parameter.
--blink.main.jar=flink-log-connector-0.1.21-snapshot.jar
-- The default state backend configuration. The configuration takes effect when the job code is not explicitly configured.
state.backend.type=niagara
state.backend.niagara.ttl.ms=129600000
-- The default checkpoint configuration. The configuration takes effect when the job code is not explicitly configured.
blink.checkpoint.interval.ms=180000
Note You can configure custom parameters. For more information, see Set custom parameters.
Verify the test result
On the Container Log tab of the Job Administration page, view information in the taskmanager.out file of the sink node. In this example, the type of the sink node is print.
If the information shown in the following figure appears, Realtime Compute for Apache
Flink reads the data from Log Service.
