You can import data from a self-managed MySQL database or a MySQL database on an ApsaraDB RDS for MySQL instance to Log Service. This way, you can query, analyze, and transform the data in Log Service. This topic describes how to import data from a MySQL database to Log Service.
Prerequisites
- A MySQL database is created. A database account is created and is granted minimum read permissions.
- An IP address whitelist is configured for the MySQL database.
You must configure an IP address whitelist based on the region of the project to which the data import task belongs and the network of the database. For more information about IP addresses, see IP address whitelists.
- A project and a Logstore are created. For more information, see Create a project and Create a Logstore.
Import data
- Log on to the Log Service console.
- In the Projects section, click the project that you want to view.
- Choose >. Then, move the pointer over and click +. . On the Logstores tab, find the Logstore that you want to manage and click
- In the Import Data dialog box, click MySQL - Data Import.
- In the Configure Import Settings step, create a data import configuration.
- Preview data, configure indexes, and then click Next. By default, full-text indexing is enabled for Log Service. You can also configure field indexes based on collected logs in manual mode or automatic mode. To configure field indexes in automatic mode, click Automatic Index Generation. This way, Log Service automatically creates field indexes. For more information, see Create indexes.Important If you want to query and analyze logs, you must enable full-text indexing or field indexing. If you enable both full-text indexing and field indexing, the system uses only field indexes.
- Click Log Query. You are redirected to the query and analysis page of your Logstore. On the page, check whether the import task of MySQL data is successful. Wait for approximately 1 minute. If you can query the MySQL data, the import task is successful.
View the data import configuration and reports
After you create a data import configuration, you can view the configuration and related reports in the Log Service console.
- In the Projects section, click the project to which the data import configuration belongs.
- Find and click the Logstore to which the data import configuration belongs, choose , and then click the data import configuration.
- On the Import Configuration Overview page, view the basic information about the data import configuration and the related reports.
What to do next
On the Import Configuration Overview page, you can perform the following operations:
- Modify the data import configuration
To modify the data import configuration, click Modify Settings. For more information, see Import data.
- Delete the data import configuration To delete the data import configuration, click Delete Configuration.Warning After a data import configuration is deleted, it cannot be restored. Proceed with caution.