Troubleshoot heartbeat issues
A machine group heartbeat monitors communication between a server and Simple Log Service (SLS). If the heartbeat is abnormal, the server cannot send data to SLS. This topic explains the causes of heartbeat issues and how to resolve them.
Causes of heartbeat issues
LoongCollector uses the following configuration items to identify the destination project and report heartbeats. To resolve heartbeat issues, verify these items and check network connectivity.
-
The Alibaba Cloud account that owns the SLS project: This account must have permissions to access and collect logs from the server.
-
The region and connection type of the project: The SLS endpoint is dynamically generated based on the region and connection type. Ensure the server can connect to this endpoint. Network connection types and endpoints.
-
Custom identifier or IP address: LoongCollector establishes a heartbeat by associating the server with a machine group through an IP address or custom identifier.
Heartbeat establishment process
-
LoongCollector reads its configuration to retrieve Alibaba Cloud account IDs, the endpoint (generated from the region and connection type), and the server's IP address or custom identifier.
-
LoongCollector reports a heartbeat to a project in the specified region.
-
Projects that meet the criteria compare the IP address or custom identifier in their machine groups with the reported information.
-
If the information matches, a heartbeat is established and the status in the corresponding machine group changes to OK.
Common scenarios for heartbeat issues
New server heartbeat is FAIL
The initial connection may take time to establish. Wait about two minutes and refresh the status. If the heartbeat is still FAIL, follow these steps:
-
Verify that you selected the correct LoongCollector installation scenario. If incorrect, uninstall and reinstall LoongCollector.
Installation method
Applicable scenario
Applies when the server is an ECS instance in the same account and region as the project.
Applies when the server is an ECS instance in the same account but a different region from the project.
Applies when the server is an ECS instance in the same region as the project but under a different account.
-
Applies when the server is not an ECS instance (on-premises or another cloud provider).
-
Also applies when the ECS instance and the project are in different accounts and different regions. Treat the server as on-premises in this case.
-
-
On the server, run
sudo /etc/init.d/loongcollectord statusto check LoongCollector status. If the output isloongcollector is running, it has started. Otherwise, start it:If you use Logtail, run
sudo /etc/init.d/ilogtaild statusto check its status andsudo /etc/init.d/ilogtaild startto start it.sudo /etc/init.d/loongcollectord start -
In a cross-account scenario, you must configure a user ID file to grant the project's account permissions to access the server and collect logs.
-
Verify the region and connection type, and confirm the server can reach the endpoint. Check if the
regionin/usr/local/ilogtail/ilogtail_config.jsonmatches the Region ID of the SLS project. If not, modify the configuration: -
Check the custom identifier or IP address:
-
Log in to the Simple Log Service console. In the project list, click the destination project.
-
In the left-side navigation pane, choose Resources > Machine Groups. On the Machine Groups page, click the target machine group.
-
On the Machine Group Configurations page, check the Machine Group Identifier and perform the corresponding action:
Custom identifier
-
Check that
/etc/ilogtail/user_defined_idexists on the server. Create it if missing. -
Write a custom string to this file as the custom identifier. This example uses
user-defined-test-1.# Write a custom string to the specified file. echo "user-defined-test-1" > /etc/ilogtail/user_defined_id -
In the console, set the value of Custom Identifier to the custom string. In this example, the value is
user-defined-test-1.
IP address
Add the
ipvalue from/usr/local/ilogtail/app_info.jsonon the server to the IP Address field in the console.IP address retrieval logic: If a hostname-to-IP-address mapping is configured in the /etc/hosts file on the server, the mapped IP address is used. If no mapping is configured, the IP address of the first network interface card (NIC) is used. If the
working_ipparameter is set in the /usr/local/ilogtail/ilogtail_config.json file, its value is used as the server's IP address. Ensure that an IP address can be retrieved by using at least one of these methods. Otherwise, theipfield will be empty, and a heartbeat cannot be established. -
-
Heartbeat changed from OK to FAIL
A previously successful heartbeat confirms your initial configuration was correct. If the machine group uses a custom identifier, the settings are static and the issue is likely network-related — check connectivity to the SLS endpoint. If the machine group uses an IP address, a FAIL status usually indicates an IP change or conflict. Follow these steps:
-
Restart LoongCollector on the server to retrieve the latest IP address.
If you use Logtail, the restart command is:
sudo /etc/init.d/ilogtaild restartsudo /etc/init.d/loongcollectord restart -
View the
ipfield in/usr/local/ilogtail/app_info.jsonon the server.IP address retrieval logic: If a hostname-to-IP-address mapping is configured in the /etc/hosts file on the server, the mapped IP address is used. If no mapping is configured, the IP address of the first network interface card (NIC) is used. If the
working_ipparameter is set in the /usr/local/ilogtail/ilogtail_config.json file, its value is used as the server's IP address. -
Log in to the Simple Log Service console. In the project list, click the destination project.
-
In the left-side navigation pane, choose Resources > Machine Groups. On the Machine Groups page, click the target machine group.
-
On the Machine Group Configurations page, check whether the IP Address field contains the value of the
ipfield from the/usr/local/ilogtail/app_info.jsonfile. If it does not, add the value of theipfield to the IP Address field. -
If the IP address matches but the heartbeat remains FAIL, the IP may be unstable or conflicting. Consider switching to a custom identifier.
Heartbeat fails after switching identifier type
If IP address conflicts or changes make IP-based machine groups unsuitable, switch to a custom identifier. This change does not affect network connectivity, account information, or region settings. Ensure the custom identifier is configured correctly:
-
Confirm that
/etc/ilogtail/user_defined_idexists. Create it if missing. -
Write a custom string to this file as the custom identifier. This example uses
user-defined-test-1.# Write a custom string to the specified file. echo "user-defined-test-1" > /etc/ilogtail/user_defined_id -
Log in to the Simple Log Service console. In the project list, click the destination project.
-
In the left-side navigation pane, choose Resources > Machine Groups. On the Machine Groups page, click the target machine group.
-
On the Machine Group Configurations page, confirm the following parameters. If incorrect, click Modify in the upper-right corner to update them.
-
Machine Group Identifier: Custom Identifier.
-
Custom identifier: The custom string. In this example, the value is
user-defined-test-1.
-
FAQ
Why is heartbeat FAIL with correct configuration?
If configurations are correct and the network is working, the heartbeat may still be FAIL for these reasons:
-
The heartbeat interval is throttled because no collection configuration has been applied in the region for a long time.
-
To reduce service load, the agent decreases its configuration request frequency when a region returns no configurations. The interval can increase up to 12 minutes. If this exceeds the heartbeat timeout threshold, the status changes to FAIL.
-
Solution: Ignore the FAIL status and apply a collection configuration to the machine group. The heartbeat recovers on the next request. To restore it immediately, restart the agent.
-
-
The running configuration does not match the current
ilogtail_config.jsonfile.-
Example: The agent starts with a non-default configuration, then
ilogtail_config.jsonis modified without restarting the agent. -
How to check:
-
The simplest solution is to restart the agent. It automatically loads the latest configuration.
-
Check the logs: If you want to avoid interrupting collection, check
/usr/local/ilogtail/ilogtail.LOG. From the beginning of the file, search forload logtail config file. The corresponding entry shows the active configuration. Verify it matches your local file.
-
-
icon to the right of the project name to open the project overview page.