The single-line mode simplifies log collection by treating each log as a single entry within Simple Log Service, without parsing the content of each log. This topic explains how to create a Logtail configuration for single-line log collection using the Simple Log Service console.
Solution overview
In single-line mode, logs are stored in the content
field without extracting additional fields. The log's timestamp corresponds to the system time at the moment of collection, which is the server time where Logtail is installed.
Consider the following original log:
Aug 19 11:20:51 hostname-1 crond[2995]: (CRON) INFO (@reboot jobs will be run at computer's startup.)
After using single-line mode for collection into Simple Log Service, the result is as follows:
Prerequisites
A machine group has been created, and servers have been added to the machine group. We recommend that you create a custom identifier-based machine group. For more information, see Create a custom identifier-based machine group or Create an IP address-based machine group.
Ports 80 (HTTP) and 443 (HTTPS) for outbound traffic are enabled for the server on which Logtail is installed. If the server is an Elastic Computing Service (ECS) instance, you can reconfigure the related security group rules to enable the ports. For more information about how to configure a security group rule, see Add a security group rule.
The server from which you want to collect logs continuously generates logs. Logtail collects only incremental logs. If a log file on your server is not updated after a Logtail configuration is delivered and applied to the server, Logtail does not collect logs from the file. For more information, see Read log files.
1. Select a project and a logstore
Log on to the Simple Log Service console.
Click Quick Data Import on the right side of the console.
On the Import Data page, click Single Line - Text Logs.
Select the project and logstore you want.
2. Configure a machine group
Apply the Logtail configuration to the specified machine group to collect data from the server. Choose the appropriate scenario and installation environment based on your requirements, because this will influence subsequent configurations.
Existing machine group
Select the desired machine group from the Source Machine Group list and click Next.
No available machine group
Click Create Machine Group and configure the parameters in the Create Machine Group panel. Machine group identities are categorized as either IP Address or Custom Identifier. For more information, see Create a custom identifier-based machine group and Create an IP address-based machine group.
ImportantIf the machine group is applied immediately after creation, the heartbeat may show a status of FAIL due to an ineffective connection. Click Retry. If the problem persists, see How do I troubleshoot an error related to a Logtail machine group in a host environment?
3. Configure a Logtail
3.1 Global configurations
3.2 Input configurations
3.3 Processor configurations
Log Sample: Supports multiple logs. Log samples can help configure log processing parameters, facilitating the setup process. We recommend that you add log samples.
Multiline Mode: Not required for this example because this example involves single-line text logs.
Processing Method: Select None.
Please note that a Logtail configuration may take up to three minutes to become effective. Kindly wait patiently.
4. Query and analysis configurations
By default, Simple Log Service enables full-text indexing. You can also manually create field indexes, or click Automatic Index Generation to automatically generate indexes. For more information, see Create indexes.
5. Query logs
Click Query Log to go to the query and analysis page.
Wait approximately one minute for the index to activate before viewing the collected logs on the Raw Logs tab. For more information, see Query and analyze logs.
To query all fields in logs, use full-text indexes. To query only specific fields, use field indexes, which helps reduce index traffic. To perform field analysis, create field indexes and include a SELECT statement in your analysis query.
What to do next
For more information about log index types, configuration examples, and index-related billing, see Create indexes.
For more information about log query syntax, see Search syntax.