You can import data from a self-managed MySQL database or an ApsaraDB RDS for MySQL instance into Simple Log Service (SLS) to query, analyze, and process the data. This topic describes how to import data from a MySQL database.
The MySQL - Data Import feature is no longer maintained and will be discontinued. The timeline and migration details will be announced later. We recommend that you use DataWorks for data synchronization. For more information, see MySQL data source.
Limits
-
This feature is supported only in the following regions: China (Hangzhou), China (Shanghai), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Chengdu), China (Shenzhen), China (Heyuan), China (Guangzhou), China (Hong Kong), Singapore, Malaysia (Kuala Lumpur), Indonesia (Jakarta), Philippines (Manila), Thailand (Bangkok), Japan (Tokyo), South Korea (Seoul), UK (London), Germany (Frankfurt), US (Virginia), and US (Silicon Valley).
-
If you import data from an AnalyticDB for MySQL source, you must convert JSON fields to the
VARCHARtype before import. For example, if a field nameddetailis of the JSON data type, usecast(detail as VARCHAR) as detailto perform the conversion. For more information about the CAST function, see CAST function.
Prerequisites
-
Create a MySQL database and a database account with read-only permissions.
-
Add the IP addresses of Simple Log Service to the IP address whitelist of your MySQL database.
Add the IP addresses for your project's region and database network type to the whitelist. For a list of required IP addresses, see IP address whitelist. For instructions on configuring a MySQL whitelist, see Configure an IP address whitelist.
-
You have created a project and a Logstore. For more information, see Manage projects and Create a basic Logstore.
Import data
Log on to the Simple Log Service console.
In the Projects section, click the one you want.

-
In the pane, click > next to the target Logstore. Hover over and click +.
-
In the Quick Data Import wizard, search for and click MySQL - Data Import.
-
Configure the data import job.
-
In the Configure Data Source step, configure the following parameters.
Advanced parameters
-
Click Preview to check the import results. After you confirm the results, click Next Configuration.
-
In the Scheduling Interval step, configure the following parameters.
Parameter
Description
Import Interval
The interval at which data is imported from the MySQL database to Simple Log Service.
Execute Now
Select Execute Now to run the import job once.
-
After the configuration is complete, click Next.
-
Create indexes and preview data. Then, click Next. By default, full-text indexing is enabled in Simple Log Service. You can also manually create field indexes for the collected logs or click Automatic Index Generation. Then, Simple Log Service generates field indexes. For more information, see Create indexes.
ImportantIf you want to query all fields in logs, we recommend that you use full-text indexes. If you want to query only specific fields, we recommend that you use field indexes. This helps reduce index traffic. If you want to analyze fields, you must create field indexes. You must include a SELECT statement in your query statement for analysis.
-
You must wait approximately 1 minute for the indexes to take effect. Then, you can view the collected logs on the Raw Logs tab. For more information about how to query and analyze logs, see Query and analysis quick start.
View the import job and statistical reports
After you create a data import job, you can view its configuration and statistical reports in the console.
-
In the Projects section, click the target project.
-
In the left-side navigation pane, choose , and then click the name of the target job.
-
On the Import Configuration Overview page, view the basic information and statistical reports for the import job.
Related operations
On the Import Configuration Overview page, you can also perform the following operations.
-
Modify a job
Click Edit Configurations to change the job configuration. For parameter details, see Import data.
-
Delete a job
Click Delete Configuration to delete the data import job.
WarningThis operation cannot be undone. Proceed with caution.