全部產品
Search
文件中心

Simple Log Service:Logtail診斷

更新時間:Jul 04, 2025

您在使用Logtail採集日誌時,可能遇到正則解析失敗、檔案路徑不正確、流量超過Shard服務能力等問題。Log Service提供診斷功能,可協助您快速定位Logtail採集錯誤資訊。

前提條件

  • 已使用Logtail採集日誌。具體操作,請參見資料擷取

  • 已開通目標Logtail配置所在Project的重要日誌採集功能。具體操作,請參見開通服務日誌

背景資訊

Logtail診斷有兩種方式,分別是控制台診斷與使用Logtail自動診斷工具,具體說明如下:

  • 控制台診斷套件括進階版診斷和基礎版診斷:

    • 進階版診斷(推薦):提供異常診斷儀錶盤,清晰展示Logtail相關的異常資訊,並且支援更長時間的異常資訊查詢。

      重要

      進階版診斷的儀錶盤依賴於Project的重要日誌。更多資訊,請參見服務日誌類型

    • 基礎版診斷:提供最近1小時內的採集異常資訊。

  • Logtail自動診斷工具,僅支援Linux系統伺服器,且需要安裝curl工具用於網路連通性檢查。流程如下:

控制台診斷

  1. 登入Log Service控制台

  2. 在Project列表地區,單擊目標Project。

    image

  3. 日誌儲存 > 日誌庫頁簽中,將滑鼠懸浮在目標Logstore上,然後單擊目標Logstore右側的Logtail組態管理表徵圖。

    image

  4. 查看診斷資訊。

    重要

    使用進階版診斷,必須開啟重要日誌。更多資訊,請參見重要日誌

    基礎版診斷

    日誌採集錯誤面板中將展示該Logstore所對應的所有Logtail採集錯誤清單。您可以單擊目標錯誤碼,查看錯誤詳情。更多資訊,請參見Log Service採集資料常見的錯誤類型錯誤類型

    進階版診斷

    LoongCollector/Logtail異常監控頁面,查看活躍用戶端數全量錯誤資訊等資訊。更多資訊,請參見查看資料報表Log Service採集資料常見的錯誤類型

  5. 處理問題完畢後,您可以查看是否仍有報錯。歷史報錯在到期前仍顯示,您可以忽略這部分報錯,僅確認在問題處理完畢的時間點之後是否有新的錯誤。其中Logtail上報錯誤資訊的時間間隔為10分鐘。

    說明

    如果您需要查看解析失敗而被丟棄的完整日誌,可查看Logtail作業記錄。路徑為:

    • 主機情境:在Logtail所在伺服器的/usr/local/ilogtail/ilogtail.LOG檔案中。

    • 容器情境:在Logtail所在容器的/usr/local/ilogtail/ilogtail.LOG檔案中。

Logtail自動診斷工具

  1. 登入已安裝Logtail的Linux伺服器,使用以下命令下載診斷工具。

    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自動診斷工具將執行下述一系列的檢查。

    1. 檢查基本資料。

      • 是否安裝Logtail。

      • 是否運行Logtail。

      • SSL狀態是否正常。

      • 與Log Service之間是否有網路連通。

      [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採集配置問題

    選擇日誌採集檢查後,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運行環境正常,建議在Log Service控制台中查看該配置項的異常日誌。更多資訊,請參見控制台診斷

診斷工具常用參數

常用參數

說明

--help

查看協助文檔。

--logFile [LogFileFullPath]

檢測Logtail是否採集LogFileFullPath路徑中的日誌,同時檢查基本的Logtail運行環境(安裝檔案完整性、運行狀態、阿里雲帳號ID、網路連通性等)。

--logFileOnly [LogFileFullPath]

只檢測Logtail是否採集LogFileFullPath路徑中的日誌。

--envOnly

只檢測Logtail運行環境。

Logtail採集異常的常見問題

運行Logtail自動診斷工具後,可以診斷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採集配置。建議去重。