Manage the lifecycle, startup parameters, and runtime configurations of LoongCollector after installation.
Common LoongCollector commands
Start, stop, and restart LoongCollector
If you have specific performance requirements for data collection, modify the startup parameter configuration file (ilogtail_config.json) before you start LoongCollector.
sudo /etc/init.d/loongcollectord start # Start
sudo /etc/init.d/loongcollectord stop # Stop
sudo /etc/init.d/loongcollectord restart # Restart
Check the LoongCollector status
sudo /etc/init.d/loongcollectord status # "loongcollector is running" indicates the agent started successfully.
Check the LoongCollector version
cat /usr/local/ilogtail/app_info.json # The version is in the loongcollector_version field.
Startup parameter configuration file (ilogtail_config.json)
-
Configures startup parameters for LoongCollector. Improper settings can degrade collection performance or cause errors.
-
File path: /usr/local/ilogtail/ilogtail_config.json.
-
If the collection performance is insufficient, you can modify the startup parameters. For specific use cases, see Solve common collection issues by modifying configurations.
-
File example:
{ "primary_region" : "cn-beijing", // Default region. You can ignore this parameter. "config_servers" : // The address used to obtain collection configurations. [ "http://logtail.cn-beijing.log.aliyuncs.com" ], "data_servers" : // The address for data transmission with Simple Log Service (SLS). [ { "region" : "cn-beijing", "endpoint_list": [ "cn-beijing.log.aliyuncs.com" ] } ], "cpu_usage_limit" : 0.4, "mem_usage_limit" : 384, "max_bytes_per_sec" : 20971520, "bytes_per_sec" : 1048576, "buffer_file_num" : 25, "buffer_file_size" : 20971520, "buffer_map_num" : 5 } -
The following table lists common startup parameters. Add or modify them as needed, and retain the default values for any parameters not listed.
Performance tuning
SLS limits LoongCollector's resource consumption to prevent it from affecting other services. You can modify the startup parameters to improve collection performance.
Recommended parameter values
The following values are recommended for collecting common JSON files. Full regular expression mode and separator mode perform similarly to JSON mode, while minimalist mode is about five times faster. Data complexity, rule complexity, and the number of monitored directories and files all affect CPU and memory consumption. Adjust the parameters based on your requirements.
Add or modify the parameter values in /usr/local/ilogtail/ilogtail_config.json and restart LoongCollector for the changes to take effect. The following table provides recommended values for different collection rates.
When you configure startup parameters based on the Collection rate greater than 40 MB/s column in the table, the collection performance approaches its limit.
|
Parameter |
Description |
Rate > 10 MB/s |
Rate > 20 MB/s |
Rate > 40 MB/s |
|
cpu_usage_limit |
The CPU usage threshold, based on a single CPU core.
A value of 0.4 means SLS attempts to limit the collector's CPU usage to 40% of a single core. If the usage exceeds this limit, LoongCollector automatically restarts. This is a soft limit. The actual CPU usage may exceed this value. If the limit is exceeded for five consecutive minutes, a circuit breaker is triggered and LoongCollector automatically restarts. |
1 |
2 |
4 |
|
mem_usage_limit |
The memory usage threshold.
The collection rate, the number of monitored directories and files, and sending congestion are affected by this parameter. For more information, see Limits. This is a soft limit. The actual memory usage may exceed this value. If the limit is exceeded for five consecutive minutes, a circuit breaker is triggered and LoongCollector automatically restarts. |
1024 |
2048 |
4096 |
|
process_thread_count |
The number of threads for data processing.
A single thread can handle 24 MB/s of data writes in minimalist mode or 12 MB/s in full regular expression mode. You do not need to adjust this parameter value under normal circumstances. |
2 |
4 |
8 |
|
max_bytes_per_sec |
The maximum rate at which raw data can be sent, in bytes per second.
Important
A value greater than 20,971,520 Byte/s (20 MB/s) indicates no speed limit. |
209715200 |
209715200 |
209715200 |
|
send_request_concurrency |
The amount of asynchronous concurrency.
If the write TPS is high, you can set a higher asynchronous concurrency value. You can estimate that each concurrent request can handle 0.5 MB/s to 1 MB/s of network throughput, depending on network latency. |
20 |
40 |
80 |
Other common configuration files
LoongCollector uses the following configuration and information files during runtime.
Collection configuration (user_log_config.json)
-
Description: Records the collection configuration that LoongCollector obtains from Simple Log Service (SLS). The file is updated whenever the collection configuration changes. Do not modify this file, except to manually configure sensitive information such as an AccessKey or database passwords.
-
Path: /usr/local/ilogtail/user_log_config.json.
-
Use case: You can check this file to confirm whether a collection configuration has been delivered to the server. If this file exists and its content matches the collection configuration in SLS, the configuration has been successfully delivered.
AppInfo file (app_info.json)
-
Description: Records LoongCollector's startup time, retrieved IP address, and hostname. This file is read-only; any modifications do not take effect.
-
Path: /usr/local/ilogtail/app_info.json.
-
Use case: View the server IP address identified by SLS to verify that it matches the IP address in the IP-based machine group. This is typically used to troubleshoot heartbeat failures in IP-based machine groups.
LoongCollector retrieves the IP address in the following order of precedence: the working_ip parameter in ilogtail_config.json, the hostname-to-IP binding in the server's /etc/hosts file, and the IP address of the first network interface card.
LoongCollector runtime log (loongcollector.LOG)
-
Description: Records LoongCollector's runtime logs. The log levels, from lowest to highest, are INFO, WARN, and ERROR.
-
Path: /usr/local/ilogtail/loongcollector.LOG.
-
Use case: If a collection error occurs, first use Diagnose and monitor LoongCollector to check for errors. Then, troubleshoot the issue by using the log collection error types and the LoongCollector runtime log.
User ID file
-
Description: Contains the Alibaba Cloud account ID of the project to which the collected logs belong. The filename is the account ID, with no suffix. Its presence indicates that this account has permission to collect logs from this server.
-
Path: /etc/ilogtail/users/{Alibaba Cloud account ID}.
-
Use case: Configure a user ID only when collecting logs from ECS instances under other accounts, self-managed servers, or servers from other cloud providers. If multiple accounts need to collect logs from the same server, create multiple user ID files on that server.
Custom identifier file
-
Description: Configures a custom identifier used as the value for a custom-identifier machine group, which helps SLS discover LoongCollector on the server and establish a heartbeat.
-
Path: /etc/ilogtail/user_defined_id.
-
Use case: Required when using a custom-identifier machine group. For more information, see Associate a machine group with a collection configuration.
Checkpoint file
-
Description: Records the current collection position to ensure data integrity.
-
Path: The default path is
/tmp/logtail_check_point. -
Use case: Manage the checkpoint file by modifying the startup parameter file. For more information, see Limits.