Logtail自动诊断工具

更新时间:2025-03-07 10:50:02

当您在使用Logtail采集日志时遇到异常,可以通过Logtail自助诊断工具快速定位和解决问题。

注意事项

  • Logtail自动诊断工具仅支持Linux系统的服务器。

  • Logtail自动诊断工具需通过curl工具进行网络连通性检查,请确保目标服务器已安装curl工具。

  • Logtail只采集增量日志。如果下发Logtail采集配置后,日志文件无更新,则Logtail不会采集该文件。更多信息,请参见读取日志

  • 默认情况下,一个文件只能匹配一个Logtail采集配置。如果您希望一份日志被多次采集,请参见如何实现文件中的日志被采集多份

诊断流程

image

操作步骤

  1. 登录已安装LogtailLinux服务器,使用以下命令下载诊断工具。

    wget http://logtail-release.oss-cn-hangzhou.aliyuncs.com/linux64/checkingtool.sh -O checkingtool.sh
  2. 输入以下命令,运行诊断工具。

    chmod 744 ./checkingtool.sh
    ./checkingtool.sh
    sh checkingtool.sh
  3. 运行诊断工具后,系统将返回如下信息,请根据提示选择语言。

    [Info]:     Logtail checking tool version : 0.3.1
    [Input]:  Please choose language 请选择语言 : 
                    1. 中文. 
                    2. English. 
            语言 :
  4. 选择语言后,系统将提示您选择不同的检查流程。您可根据具体情况输入12

    [Input]:  please choose which type you want to check : 
                    1. MachineGroup heartbeat fail. 
                    2. MachineGroup heartbeat is ok, but log files have not been collected. 
            Type :
    • 1:如果机器组心跳异常,请选择此项检查机器组问题。

    • 2:如果机器组心跳正常,但日志文件没有被采集到,请选择此项检查Logtail采集配置问题。

    检查机器组问题
    检查Logtail采集配置问题

    选择机器组心跳异常检查后,Logtail自动诊断工具将执行下述一系列的检查。

    1. 检查基本信息。

      • 是否安装Logtail。

      • 是否运行Logtail。

      • SSL状态是否正常。

      • 与日志服务之间是否有网络连通。

      [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_2.0.8 exists.                [ OK ]
      [Info]:     Logtail version : 2.0.8                                             [ OK ]
      
      [Info]:     Check Logtail running status
      [Info]:     Logtail is runnings.                                                [ OK ]
      [Info]:     Check network status
      [Info]:     Logtail is using ip: 172.31.0.246
      [Info]:     Logtail is using UUID: D1BA8F5A-FA52-11EF-8935-00163E4C****
      [Info]:     Check SSL status
      Redirecting to /bin/systemctl status iptables.service
      Unit iptables.service could not be found.
      [Info]:     SSL status OK.                                                      [ OK ]
      [Info]:     Check logtail config server
      [Info]:     config server address: http://logtail.cn-hangzhou-intranet.log.aliyuncs.com
      [Info]:     Logtail config server HTTP OK                                       [ OK ]
      [Info]:     Logtail config server HTTPS OK                                      [ OK ]
    2. 检查您的服务器是否为阿里云ECS并且和当前SLS Project属于同一账号。

      • 如果是,请输入y继续下一步。

      • 否则,请输入N。输入N后,诊断工具将输出本地配置的用户标识信息。如果您的阿里云账号ID不在其中,请重新配置用户标识

        [Input]:  Is your server Alibaba Cloud ECS and belong to the same account of the current SLS Project ? (y/N)n
        [Info]:     Check aliyun user id(s)
        [Info]:     aliyun user id : 198********815 .                                 [ OK ]
        
        [Input]:  Is your project owner account ID among the above IDs ? (y/N)n
        [Error]:    please configure user IDs (account IDs), this doc will help
                    [ https://www.alibabacloud.com/help/doc-detail/49007.htm ]          [ Error ]
    3. 检查您Project所在地域是否和安装Logtail时所选地域一致。

      • 如果一致,请输入y继续下一步。

      • 否则,请输入N。输入N后,诊断工具将提示您重新安装Logtail或者重新创建Project,确保Project的地域和Logtail安装时选择的地域相同。具体操作,请参见安装Logtail(Linux系统)

        [Input]:  please make sure your project is in this region : { cn-hangzhou } (y/N) :n
        [Error]:    please reinstall your Logtail or recreate your project to
                    make sure your project is located in the same region with your Logt [ Error ]
    4. 检查您机器组中配置的IP地址或用户自定义标识是否与提示信息中的一致。

      • 如果一致,请输入y。诊断工具将生成报告,如果问题依然存在,请复制输出报告内容并提交工单

      • 否则,请输入N。诊断工具将提示您修正机器组中的IP或自定义标识。具体操作,请参见修改机器组信息

        [Input]:  please make sure your machine group's ip is same with : { 172.31.0.246 } or your machine group's userdefined-id is in : { user-defined-linux-1 } (y/N) :n
        [Error]:    please correct your machine group's ip or userdefined-id,
                    save the configuration, wait 1 minute and check again               [ Error ]

    选择日志采集检查后,Logtail自动诊断工具将执行下述一系列的检查。

    1. 请确认您的机器组心跳正常并且检查机器组中配置的IP地址是否与提示信息中的一致。

      • 如果是,请输入y继续下一步。

      • 否则,请输入N。输入N后,诊断工具将提示您返回检查机器组问题

        [Input]:  please make sure your machine's heartbeat is ok and machine group's ip is same with : { 172.31.0.246 } (y/N) :n
        [Error]:    please rerun the script and choose type 1 to check machine group's  [ Error ]
    2. 检查您的Logtail采集配置是否已应用到目标机器组中。

      • 如果是,请输入y继续下一步。关于如何检查,请参见查看机器组配置

      • 否则,请输入N。输入N后,诊断工具将提示您应用Logtail采集配置到指定机器组

        [Input]:  please make sure you have applied collection config to the machine group (y/N) :n
        [Error]:    please apply collection config to the machine group                 [ Error ]
    3. 检查Logtail采集配置中的日志文件路径是否正确。

      检查时,请输入您需要检查的日志文件全路径。如果未找到匹配项,请确认配置的路径是否可以匹配目标文件。

      如果配置错误,请修改Logtail采集配置,然后等待1分钟后再次执行此脚本重新检查。

      [Input]:  please input your log file's full path (eg. /var/log/nginx/access.log) : /var/log/nginx/access.log
      [Info]:     Check specific log file
      [Info]:     Check if specific log file [ /var/log/nginx/access.log ] is included by user log config.
      [Info]:     Specific log file exists.                                           [ OK ]
      [Error]:    No match config for your log file.                                  [ Error ]
      [Suggestion]:  Please check collection config is created in SLS Project/Logstore and make sure you have applied config to your machine group
    4. 如果上述步骤检查完毕后,依然存在问题,请复制诊断报告并提交工单

      [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
      [Info]:     Check system support
      [Info]:     Check system support OK.                                            [ OK ]
      
      [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_2.0.8 exists.                [ OK ]
      [Info]:     Logtail version : 2.0.8                                             [ OK ]
      ......
      ......

运行快速检查

运行快速检查时,会输出您在Logtail客户端中配置的用户标识(阿里云账号ID)和机器组的自定义用户标识。如果不存在,也不会告警。如果您设置了这些信息,请查看提示信息中的内容与您设置的是否一致。如果不一致,请按照配置用户标识创建用户自定义标识机器组重新配置。

您可以使用以下命令进行快速检查:

./checkingtool.sh --logFile [LogFileFullPath]

如果指定的日志文件检查通过且Logtail运行环境正常,建议在日志服务控制台中查看该配置项的异常日志。更多信息,请参见如何查看Logtail采集错误信息

诊断工具常用参数

常用参数

说明

常用参数

说明

--help

查看帮助文档。

--logFile [LogFileFullPath]

检测Logtail是否采集LogFileFullPath路径中的日志,同时检查基本的Logtail运行环境(安装文件完整性、运行状态、阿里云账号ID、网络连通性等)。

--logFileOnly [LogFileFullPath]

只检测Logtail是否采集LogFileFullPath路径中的日志。

--envOnly

只检测Logtail运行环境。

Logtail采集异常的常见问题

运行Logtail自动诊断工具后,可以诊断Logtail采集异常的原因,您可以根据具体原因查找对应的解决方案。常见Logtail采集问题原因及解决方案如下。

常见问题

解决方法

常见问题

解决方法

安装文件丢失

重装Logtail。

Logtail未运行

执行/etc/init.d/ilogtaild start命令,启动Logtail。

多个Logtail进程

  1. 执行/etc/init.d/ilogtaild stop命令,关闭Logtail。

  2. 执行/etc/init.d/ilogtaild start命令,启动Logtail。

443端口被禁用

在防火墙中,开启443端口。

无法找到配置服务器

确认是否已正确安装Logtail。

如果安装错误,请重新执行安装命令。更多信息,请参见安装Logtail(Linux系统)

不存在用户配置

确认是否已执行以下操作:

  1. 已创建Logtail采集配置。

  2. 机器组中包含该服务器。

  3. 已经将Logtail采集配置应用到机器组。

没有匹配指定日志文件

确认是否正确创建Logtail采集配置。

指定日志文件匹配多次

匹配多次时,Logtail会随机选择一个Logtail采集配置。建议去重。

  • 本页导读 (1)
  • 注意事项
  • 诊断流程
  • 操作步骤
  • 运行快速检查
  • 诊断工具常用参数
  • Logtail采集异常的常见问题