If an error occurs when you use Logtail to collect logs, you can use the automatic diagnostic tool of Logtail to check whether the error occurs on the Logtail client. This way, you can efficiently identify and fix the error.

Notice The automatic diagnostic tool of Logtail is available only for Linux servers.

Diagnostic process

Diagnostic process

Download and run the diagnostic tool

  1. Log on to a Linux server.
  2. Download the diagnostic tool script.
    wget http://logtail-release.oss-cn-hangzhou.aliyuncs.com/linux64/checkingtool.sh -O checkingtool.sh
    If you cannot download the diagnostic tool script by running the preceding command, run the following command to download the script from the secondary address:
    wget http://logtail-corp.oss-cn-hangzhou-zmf.aliyuncs.com/linux64/checkingtool.sh -O checkingtool.sh
  3. Install the curl tool.

    The automatic diagnostic tool of Logtail uses the curl tool to check the network connectivity. Make sure that the curl tool is installed on the Linux server.

  4. Run the diagnostic tool.
    chmod 744 ./checkingtool.sh
    ./checkingtool.sh
    sh checkingtool.sh
    Information similar to the following example is returned:
    [Info]:     Logtail checking tool version : 0.3.0
    [Input]:  please choose which item you want to check :
                 1. MachineGroup heartbeat fail.
                 2. MachineGroup heartbeat is ok, but log files have not been collected.
    Item :
  5. Enter 1 or 2 as prompted. The script performs different checks based on the option that you select.
    • 1: The script checks the heartbeat status of the machine group. If the heartbeat status of the machine group is FAIL, select this option.
    • 2: The script checks whether errors occur when Logtail collects logs. If the heartbeat status of the machine group is OK but no log file is collected, select this option.

Check the heartbeat status of the machine group

If you enter 1 to check the issue that Log Service cannot receive heartbeats from the Logtail client, the automatic diagnostic tool of Logtail performs the following checks:

  1. Check whether the basic environment is stable.
    • Check whether Logtail is installed.
    • Check whether Logtail is running.
    • Check whether the status of Secure Sockets Layer (SSL) encryption is normal.
    • Check whether the network connection between Logtail and Log Service is normal.
    [Info]:     Logtail checking tool version : 0.3.0
    [Input]:  please choose which item you want to check :
                    1. MachineGroup heartbeat fail.
                    2. MachineGroup heartbeat is ok, but log files have not been collected.
            Item : 1
    [Info]:     Check logtail install files
    [Info]:     Install file: ilogtail_config.json exists.                          [ OK ]
    [Info]:     Install file: /etc/init.d/ilogtaild exists.                         [ OK ]
    [Info]:     Install file: ilogtail exists.                                      [ OK ]
    [Info]:     Bin file: /usr/local/ilogtail/ilogtail_0.14.2 exists.               [ OK ]
    [Info]:     Logtail version :                                                   [ OK ]
    [Info]:     Check logtail running status
    [Info]:     Logtail is runnings.                                                [ OK ]
    [Info]:     Check network status
    [Info]:     Logtail is using ip: 11.XX.XX.187
    [Info]:     Logtail is using UUID: 0DF18E97-0F2D-486F-B77F-XXXXXXXXXXXX
    [Info]:     Check SSL status
    [Info]:     SSL status OK.                                                      [ OK ]
    [Info]:     Check logtail config server
    [Info]:     config server address: http://config.sls.aliyun-inc.com
    [Info]:     Logtail config server OK                                            [ OK ]

    If an Error message appears, fix the error as prompted.

  2. Check whether the server is an Elastic Compute Service (ECS) instance of the current Alibaba Cloud account.
    [Input]: Is your server non-Alibaba Cloud ECS or not belong to the same account with the current Project of Log Service ? (y/N)
    • If the server is an ECS instance of the current Alibaba Cloud account, enter N.
    • If the server is an ECS instance that belongs to another Alibaba Cloud account, a server that is provided by a third-party cloud service provider, or a self-managed data center, enter y.

      If you enter y, the diagnostic tool returns the information about the locally configured user identifiers. Check whether the ID of your Alibaba Cloud account is included. If the ID of your Alibaba Cloud account is not included, configure a user identifier. For more information, see Configure a user identifier.

      [Input]:  Is your server non-Alibaba Cloud ECS or not belong to the same account with the current Project of Log Service ? (y/N)y
      [Info]:     Check aliyun user id(s)
      [Info]:     aliyun user id : 126XXXXXXXXXX79 .                                 [ OK ]
      [Info]:     aliyun user id : 165XXXXXXXXXX50 .                                 [ OK ]
      [Info]:     aliyun user id : 189XXXXXXXXXX57 .                                 [ OK ]
      [Input]:  Is your project owner account ID is the above IDs ? (y/N)
  3. Check whether the region where your project resides is the same as the region that you selected when you install Logtail.
    [Input]: please make sure your project is in this region : { cn-hangzhou } (y/N) :

    If the regions are different, reinstall Logtail. For more information, see Install Logtail on a Linux server.

  4. Check whether the IP address or custom ID in your machine group is the same as the IP address or custom ID that is displayed in the returned message.
    [Input]:  please make sure your machine group's ip is same with : { 11.XX.XX.187 } or your machine group's userdefined-id is in : { XX-XXXXX } (y/N) :

    If the IP addresses or custom IDs are different, modify the IP address or custom ID in the machine group. For more information, see Modify a machine group.

Check whether errors occur when Logtail collects logs

If you enter 2 to check whether errors occur when Logtail collects logs, the automatic diagnostic tool of Logtail performs the following checks:

  1. Check whether the IP address in your machine group is the same as the IP address that is displayed in the returned message.
    [Input]:  please make sure your machine group's ip is same with : { 11.XX.XX.187 } (y/N) :

    If the IP addresses are different, modify the IP address in the machine group. For more information, see Modify a machine group.

  2. Check whether your Logtail configuration is applied to the machine group.
    [Input]: please make sure you have applied collection config to the machine group (y/N) :Y

    If the Logtail configuration is not applied to the machine group, apply the Logtail configuration to the machine group. For more information, see Manage Logtail configurations.

  3. Check whether the log file in the Logtail configuration is valid.

    You must enter the full path of the log file that you want to check. If no file is matched, check whether the specified path can match the file.

    If the log file path is invalid, modify the Logtail configuration, and then run the script to repeat the check after 1 minute. For more information about how to modify a Logtail configuration, see Modify Logtail configurations.

    [Input]:  please input your log file's full path (eg. /var/log/nginx/access.log) :/disk2/logs/access.log
    [Info]:     Check specific log file
    [Info]:     Check if specific log file [ /disk2/logs/access.log ] is included by user config.
    [Warning]:  Specific log file doesnt exist.                                     [ Warning ]
    [Info]:     Matched config found:                                               [ OK ]
    [Info]:     [Project] -> sls-zc-xxxxxx
    [Info]:     [Logstore] -> release-xxxxxxx
    [Info]:     [LogPath] -> /disk2/logs
    [Info]:     [FilePattern] -> *.log

Submit a ticket if the issue still persists when all checks are passed

If the Logtail client passes all checks but still cannot collect logs, enter y for the last option in the script and press Enter. Information similar to the following example is returned:
[Input]: please make sure all the check items above have passed. If the problem persists, please copy all the outputs and submit a ticket in the ticket system. : (y/N)y

Press y to submit a ticket. You must include the output of the check script in the ticket.

Run a quick check

You can run a quick check without confirmation. You can encapsulate and customize a quick check script.
Note During a quick check, the diagnostic tool returns the user identifier (Alibaba Cloud account ID) that is configured on the server and the custom ID of the machine group. If no user identifier or custom ID exists, no alert is triggered. If you have configured the settings, check whether the user identifier or custom ID is the same as the user identifier or custom ID in the returned message. If the user identifiers or custom IDs are different, use the following method to reconfigure the settings:
Run the ./checkingtool.sh --logFile [LogFileFullPath] command to perform a quick check. If an Error message appears, fix the error as prompted.
Note If the specified log file passes the check and the Logtail runtime environment is normal, we recommend that you view the error logs of the related parameters in the Log Service console. For more information, see How do I view Logtail collection errors?.
result

Common Logtail collection errors

You can use the automatic diagnostic tool of Logtail to identify the causes of errors that occur when Logtail collects logs and fix the errors based on the causes. The following table describes the causes of common Logtail collection errors and the related solutions.

Error Solution
Installation files are missing. Reinstall Logtail.
Logtail is not running. Run the /etc/init.d/ilogtaild start command to start Logtail.
Multiple Logtail processes exist.
  1. Run the /etc/init.d/ilogtaild stop command to stop Logtail.
  2. Run the /etc/init.d/ilogtaild start command to start Logtail.
Port 443 is disabled. Configure the firewall to enable port 443.
The configuration server cannot be found. Check whether Logtail is installed on a Linux server.

If Logtail is not installed on the Linux server, rerun the installation command. For more information, see Install Logtail on a Linux server.

The user configuration does not exist. Check whether the following operations are performed:
  1. A Logtail configuration is created.
  2. The server is included in a machine group.
  3. The Logtail configuration is applied to the machine group.
The specified log file cannot be matched. Check whether the Logtail configuration is valid.
The specified log file is matched by more than one Logtail configurations. If the log file is matched by more than one Logtail configurations, Logtail randomly selects a Logtail configuration. We recommend that you use only one Logtail configuration to match the log file.

Common parameters of the diagnostic tool

Parameter Description
--help Views the help documentation.
--logFile [LogFileFullPath] Checks whether Logtail collects logs from the LogFileFullPath path and checks the properties of the basic runtime environment of Logtail, such as the integrity of installation files, runtime status, Alibaba Cloud account ID, and network connectivity.
--logFileOnly [LogFileFullPath] Checks whether Logtail collects logs from the LogFileFullPath path.
--envOnly Checks the properties of the runtime environment of Logtail.