You can import Pub/Sub messages from Google Cloud to Log Service to analyze and transform message data. This topic describes how to import Pub/Sub messages from Google Cloud to Log Service.
Prerequisites
- A pull subscription is created in Google Cloud Pub/Sub. For more information, see Create and use subscriptions.
- A service account is created in Google Cloud, and the key file of the service account is downloaded. For more information, see Create service accounts.
When you create the service account, you must assign the Google Cloud Pub/Sub Editor role to the service account.
- A project and a Logstore are created. For more information, see Create a project and Create a Logstore.
Create a data import configuration
- 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 Google Cloud Pub/Sub - 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 Google Cloud Pub/Sub messages is successful. Wait for approximately 1 minute. If you can query the Google Cloud Pub/Sub messages, the import task is successful.
View the data import configuration
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.
- In the left-side navigation pane, choose . Click the Logstore to which the data import configuration belongs, choose , and then click the name of the data import configuration.
- On the Import Configuration Overview page, view the basic information and reports of the data import configuration.
What to do next
On the Import Configuration Overview page, you can perform the following operations on the data import configuration:
- Modify the data import configuration
To modify the data import configuration, click Modify Settings. For more information, see Create a data import configuration.
- 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.
- Stop the data import job
To stop the data import task, click Stop.