All Products
Search
Document Center

Simple Log Service:How do I use the automatic diagnostic tool of Logtail?

Last Updated:Jan 24, 2024

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 Logtail. This way, you can efficiently identify and fix the error based on the tooltips.

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

  • Logtail collects only incremental logs. If a log file on a server is not updated after the applied Logtail configuration is delivered to the server, Logtail does not collect logs from the file. For more information, see Read log files.

Diagnostic process

image

Download and run the diagnostic tool

  1. Log on to a Linux server.

  2. Download the script of the diagnostic tool.

    wget http://logtail-release.oss-cn-hangzhou.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 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 system executes the script to perform a check based on the option that you select.

    • 1: The system checks the heartbeat status of the machine group. If the heartbeat status of the machine group is FAIL, select this option.

    • 2: The system checks whether errors occur when Logtail collects logs. If the heartbeat status of the machine group is OK but no log files are collected, select this option.

Check the heartbeat status of the machine group

If you enter 1 to check the heartbeat status of the machine group, 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 SSL encryption is normal.

    • Check whether the network connection between Logtail and Simple 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 your server is an Elastic Compute Service (ECS) instance that belongs to 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 your server is an ECS instance that belongs to the current Alibaba Cloud account, enter N.

    • If your server is an ECS instance that belongs to a different Alibaba Cloud account from Simple Log Service, a server in a data center, or a server from a third-party cloud service provider, 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 in which your project resides is the same as the region that you select 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 identifier in your machine group is the same as the IP address or custom identifier 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 identifiers are different, change the IP address or custom identifier 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, change 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 Apply Logtail configurations to a machine group.

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

    You must enter the full path to 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 wait for 1 minute. Then, run the script to repeat the check. 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 persists when all checks are passed

If all checks are passed but Logtail 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

Submit a ticket. You must include the output of the script in the ticket.

Run a quick check

You can run a quick check without confirmation. You can run a quick check for re-encapsulation. You can use a custom script.

Note

During a quick check, the diagnostic tool returns the user identifier that is specified in the Logtail configuration. A user identifier is usually an Alibaba Cloud account ID. If no user identifier or custom identifier exists, no alert is triggered. If you have configured the settings, check whether the configured user identifier or custom identifier is the same as the user identifier or custom identifier in the returned message. If the user identifiers or custom identifiers 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 Simple 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 your 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 found.

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 attributes of the basic runtime environment of Logtail, including 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 attributes of the runtime environment of Logtail.