本文件提供的資訊可協助您診斷及解決作業套件代理程式安裝和啟動時發生的問題。如果代理程式正在執行,但無法擷取記錄或指標,請參閱資料擷取疑難排解。
事前準備
著手修正問題前,請先檢查代理程式的健康狀態檢查狀態。
無法安裝代理程式
執行安裝指令碼時,您可能會遇到下列錯誤。
系統不支援該作業系統
如果作業系統不受支援,Ops Agent 安裝作業就會失敗。錯誤訊息可能會類似以下內容:
Linux
https://packages.cloud.google.com/yum/repos/google-cloud-ops-agent-el6-x86_64-all/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found" Trying other mirror. To address this issue please refer to the below wiki article https://wiki.centos.org/yum-errors If above article doesn't help to resolve this issue please use https://bugs.centos.org/. Error: Cannot retrieve repository metadata (repomd.xml) for repository: google-cloud-ops-agent. Please verify its path and try again
已安裝與作業套件代理程式相衝突的舊版代理程式
如果 VM 已安裝 Cloud Logging 代理程式或 Cloud Monitoring 代理程式,則會與新代理程式發生衝突。錯誤訊息可能會類似以下內容:
Linux
Error: Problem: problem with installed package stackdriver-agent-6.0.5-1.el8.x86_64 - package google-cloud-ops-agent-0.1.0-1.el8.x86_64 conflicts with stackdriver-agent provided by stackdriver-agent-6.0.5-1.el8.x86_64
Ops Agent 使用新的設定檔,與舊版代理程式不相容。詳情請參閱「設定 Ops Agent」指南。
如要修正這項錯誤,請執行下列操作:
為 Cloud Monitoring 代理程式和 Cloud Logging 代理程式 儲存自訂設定檔。
解除安裝舊版 Cloud Monitoring 代理程式和 Cloud Logging 代理程式。
卸除代理程式後, Google Cloud 主控台可能需要最多一小時的時間才能回報這項變更。
在 Monitoring 代理程式安裝失敗後,作業套件代理程式安裝失敗
安裝監控代理程式失敗後,作業套件代理程式安裝作業也會失敗。在 Debian 作業系統上,作業套件代理程式安裝失敗時,會顯示類似以下的錯誤訊息:
Linux
... E: The repository 'https://packages.cloud.google.com/apt google-cloud-monitoring-jammy-all Release' does not have a Release file. ... Could not refresh the google-cloud-ops-agent apt repositories.
如果您嘗試在該代理程式不支援的作業系統上安裝 Monitoring 代理程式,安裝作業就會失敗。在系統中新增監控代理程式存放區後,就會發生安裝失敗。在監控代理程式安裝失敗後,安裝作業套件代理程式也會失敗,因為監控代理程式存放區無效。
監控代理程式支援的作業系統,不一定與 Ops 代理程式支援的作業系統相同。如要瞭解支援的作業系統,請參閱「Ops Agent:Linux 作業系統」和「監控代理程式:Linux 作業系統」。
如要安裝作業套件代理程式,請按照下列步驟操作:
移除監控代理程式的存放區:
如果系統中含有指令碼
add-monitoring-agent-repo.sh
,請執行下列指令:sudo bash add-monitoring-agent-repo.sh --remove-repo
否則,請手動移除存放區:
Debian
sudo rm /etc/apt/sources.list.d/google-cloud-monitoring.list
RHEL
sudo rm /etc/yum.repos.d/google-cloud-monitoring.repo
Suse
sudo rm /etc/zypp/repos.d/google-cloud-monitoring.repo
執行作業套件代理程式安裝指令碼。
存放區重新整理失敗,因此無法安裝作業套件代理程式
安裝的存放區重新整理失敗,因此無法安裝作業套件代理程式。
Linux
如需 Debian 作業系統的失敗訊息範例,其中因呼叫 apt-get update
而發生存放區重新整理,請參閱疑難排解項目「在 Monitoring 代理程式安裝失敗後,作業套件代理程式安裝失敗」。
如果在重新整理存放區時發生錯誤,您必須先解決這些錯誤,才能安裝作業套件代理程式。您可以刪除或停用不必要的存放區,或許就能解決這些失敗問題。
重新整理存放區後,您就可以執行作業套件代理程式安裝指令碼,安裝作業套件代理程式。
無法取得公開金鑰,因此無法重新整理存放區
Linux
由於無法取得公開金鑰,因此因呼叫 apt-get update
而導致的存放區重新整理作業會失敗。安裝或升級 Ops Agent 時也可能發生這種情況。您可能會看到下列失敗訊息:
W: GPG error: http://packages.cloud.google.com/apt google-cloud-ops-agent-focal-all InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY C0BA5CE6DC6315A3
E: The repository 'http://packages.cloud.google.com/apt google-cloud-ops-agent-focal-all InRelease' is not signed.
如要修正這項錯誤,請執行下列指令,將缺少的鍵新增至系統:
curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg \
| sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/google-cloud-ops-agent.gpg
代理程式已安裝,但未執行
如果您已安裝代理程式,但代理程式未執行,問題可能出在下列任一情況:
- 其中一個主要元件 (「Metrics Agent」或「Logging Agent」) 無法啟動;請參閱「代理程式服務未執行」。
- VM 上也安裝了其中一個舊版代理程式,請參閱「與目前已安裝的代理程式發生衝突」。
- 某個元件所需的通訊埠已由其他程序使用;請參閱「無法使用的通訊埠」。
- 作業套件代理程式的設定無效,請參閱「無效的設定」。
代理服務未執行
如果代理程式服務運作正常,查詢狀態時,指標代理程式和記錄代理程式會列為執行中:
適用於 Linux
sudo systemctl status google-cloud-ops-agent"*"
為求簡潔,我們已刪除輸出內容中的部分內容。
● google-cloud-ops-agent.service - Google Cloud Ops Agent Loaded: loaded (/lib/systemd/system/google-cloud-ops-agent.service; enabled; vendor preset: enabled) Active: active (exited) since Wed 2023-05-03 21:22:28 UTC; 4 weeks 0 days ago Process: 3353828 ExecStartPre=/opt/google-cloud-ops-agent/libexec/google_cloud_ops_agent_engine -in /etc/go> Process: 3353837 ExecStart=/bin/true (code=exited, status=0/SUCCESS) Main PID: 3353837 (code=exited, status=0/SUCCESS) CPU: 195ms [...] ● google-cloud-ops-agent-opentelemetry-collector.service - Google Cloud Ops Agent - Metrics Agent Loaded: loaded (/lib/systemd/system/google-cloud-ops-agent-opentelemetry-collector.service; static) Active: active (running) since Wed 2023-05-03 21:22:29 UTC; 4 weeks 0 days ago Process: 3353840 ExecStartPre=/opt/google-cloud-ops-agent/libexec/google_cloud_ops_agent_engine -service=ot> Main PID: 3353855 (otelopscol) Tasks: 9 (limit: 2355) Memory: 65.3M CPU: 40min 31.555s CGroup: /system.slice/google-cloud-ops-agent-opentelemetry-collector.service └─3353855 /opt/google-cloud-ops-agent/subagents/opentelemetry-collector/otelopscol --config=/run/g> [...] ● google-cloud-ops-agent-fluent-bit.service - Google Cloud Ops Agent - Logging Agent Loaded: loaded (/lib/systemd/system/google-cloud-ops-agent-fluent-bit.service; static) Active: active (running) since Wed 2023-05-03 21:22:29 UTC; 4 weeks 0 days ago Process: 3353838 ExecStartPre=/opt/google-cloud-ops-agent/libexec/google_cloud_ops_agent_engine -service=fl> Main PID: 3353856 (google_cloud_op) Tasks: 31 (limit: 2355) Memory: 58.3M CPU: 29min 6.771s CGroup: /system.slice/google-cloud-ops-agent-fluent-bit.service ├─3353856 /opt/google-cloud-ops-agent/libexec/google_cloud_ops_agent_wrapper -config_path /etc/goo> └─3353872 /opt/google-cloud-ops-agent/subagents/fluent-bit/bin/fluent-bit --config /run/google-clo> [...] ● google-cloud-ops-agent-diagnostics.service - Google Cloud Ops Agent - Diagnostics Loaded: loaded (/lib/systemd/system/google-cloud-ops-agent-diagnostics.service; disabled; vendor preset: e> Active: active (running) since Wed 2023-05-03 21:22:26 UTC; 4 weeks 0 days ago Main PID: 3353819 (google_cloud_op) Tasks: 8 (limit: 2355) Memory: 36.0M CPU: 3min 19.488s CGroup: /system.slice/google-cloud-ops-agent-diagnostics.service └─3353819 /opt/google-cloud-ops-agent/libexec/google_cloud_ops_agent_diagnostics -config /etc/goog> [...]
Windows 適用
Get-Service google-cloud-ops-agent* Status Name DisplayName ------ ---- ----------- Running google-cloud-op... Google Cloud Ops Agent Running google-cloud-op... Google Cloud Ops Agent - Logging Agent Running google-cloud-op... Google Cloud Ops Agent - Metrics Agent Running google-cloud-op... Google Cloud Ops Agent - Diagnostics
如果代理程式服務未執行,您可能會看到下列狀態:
Linux
$ sudo service google-cloud-ops-agent status ● google-cloud-ops-agent.service - Google Cloud Ops Agent Loaded: loaded (/lib/systemd/system/google-cloud-ops-agent.service; enabled; vendor preset: enabled) Active: inactive (dead) since Wed 2021-06-30 21:20:43 UTC; 6s ago
Windows
Get-Service google-cloud-ops-agent Status Name DisplayName ------ ---- ----------- Stopped google-cloud-ops-agent Google Cloud Ops Agent
如要修正這項錯誤,請執行下列指令啟動服務:
Linux
sudo service google-cloud-ops-agent start
Windows
Start-Service google-cloud-ops-agent
如果服務無法啟動,表示設定可能無效。
與目前已安裝的代理程式發生衝突
VM 已安裝 Cloud Logging 代理程式或 Cloud Monitoring 代理程式,且其設定與新代理程式的設定相衝突。錯誤訊息可能如下所示:
Windows
We detected an existing Windows service for the StackdriverLogging agent, which is not compatible with the Ops Agent when the Ops Agent configuration has a non-empty logging section. Please either remove the logging section from the Ops Agent configuration, or disable the StackdriverLogging agent, and then retry enabling the Ops Agent.
如要修正這項錯誤,您有兩種方法:
停用作業套件設定檔中發生衝突的部分。詳情請參閱「設定 Ops Agent」指南。
停用發生衝突的 Cloud Logging 代理程式或 Cloud Monitoring 代理程式。
- 儲存 Cloud Logging 代理程式的任何自訂設定檔。
- 解除安裝舊版 Cloud Monitoring 代理程式和 Cloud Logging 代理程式。
卸除代理程式後, Google Cloud 主控台可能需要最多一小時的時間才能回報這項變更。
無法使用必要的通訊埠
如果元件所需的連接埠遭其他程序使用,Ops Agent 或其中一個元件可能無法啟動。作業套件代理程式會使用下列通訊埠:
- 通訊埠 20201 (適用於「Metrics Agent」元件)
- 埠 20202 (適用於「Logging Agent」元件)
如果除了 Ops Agent 元件以外的程序使用 20201 或 20202 通訊埠,請停止該程序並重新啟動 Ops Agent。請按照下列步驟判斷哪個程序正在使用這些連接埠:
Linux
Metrics Agent 元件:如要查看哪個程序使用了 20201 通訊埠,請使用下列指令:
sudo netstat -ns -p | grep '20201'
以下輸出內容顯示預期結果:作業套件代理程式指標收集器 otelopscol
正在使用連接埠:
tcp 0 0 127.0.0.1:50138 127.0.0.1:20201 ESTABLISHED 16850/otelopscol tcp6 0 0 :::20201 :::* LISTEN 16850/otelopscol tcp6 0 0 127.0.0.1:20201 127.0.0.1:50138 ESTABLISHED 16850/otelopscol
記錄代理程式元件:如要查看哪個程序使用了 20202 通訊埠,請使用下列指令:
sudo netstat -ns -p | grep '20202'
以下輸出內容顯示預期結果:作業套件代理程式記錄收集器 fluent-bit
正在使用連接埠:
tcp 0 0 0.0.0.0:20202 0.0.0.0:* LISTEN 16640/fluent-bit tcp 0 0 127.0.0.1:20202 127.0.0.1:52998 TIME_WAIT -
Windows
Metrics Agent 元件:如要查看哪個程序使用了 20201 通訊埠,請使用下列指令:
netstat -na -b | Select-String "20201" -Context 0,1
以下輸出內容顯示預期結果:作業套件代理程式指標收集器 google-cloud-metrics-agent_windows_amd64.exe
正在使用通訊埠:
> TCP 0.0.0.0:20201 0.0.0.0:0 LISTENING [google-cloud-metrics-agent_windows_amd64.exe] > TCP 127.0.0.1:20201 127.0.0.1:50090 ESTABLISHED [google-cloud-metrics-agent_windows_amd64.exe] > TCP 127.0.0.1:50090 127.0.0.1:20201 ESTABLISHED [google-cloud-metrics-agent_windows_amd64.exe] > TCP [::]:20201 [::]:0 LISTENING [google-cloud-metrics-agent_windows_amd64.exe]
記錄代理程式元件:如要查看哪個程序使用了 20202 通訊埠,請使用下列指令:
netstat -na -b | Select-String "20202" -Context 0,1
以下輸出內容顯示預期結果:作業套件代理程式記錄收集器 fluent-bit.exe
正在使用連接埠:
> TCP 0.0.0.0:20202 0.0.0.0:0 LISTENING [fluent-bit.exe] > TCP 127.0.0.1:20202 127.0.0.1:57535 TIME_WAIT > TCP 127.0.0.1:20202 127.0.0.1:57539 TIME_WAIT TCP 127.0.0.1:49807 127.0.0.1:49808 ESTABLISHED
作業套件代理程式執行的健康狀態檢查可偵測通訊埠可用性錯誤。
服務專員缺少 API 權限
如果代理程式無法啟動或擷取資料,可能是因為「Metrics Agent」或「Logging agent」元件缺少存取 API 的必要權限。
營運代理程式使用的服務帳戶需要下列身分與存取權管理角色:
- 「Logging Agent」元件:Logs Writer (
roles/logging.logWriter
) - 「Metrics Agent」元件:Monitoring 指標寫入者 (
roles/monitoring.metricWriter
)。
這些角色包含寫入記錄或指標資料所需的權限,且必須授予與 VM 相關聯的服務帳戶。您使用的服務帳戶取決於您設定 VM 和授權代理程式的方式。您可能使用下列其中一種服務:
如要找出與 VM 相關聯的服務帳戶,請按照下列步驟操作:
-
前往 Google Cloud 控制台的「VM instances」(VM 執行個體) 頁面:
如果您是使用搜尋列尋找這個頁面,請選取子標題為「Compute Engine」的結果。
如有必要,請按一下 Google Cloud 專案的下拉式清單,然後選取專案名稱。
視需要選取「Instances」分頁標籤。
在 VM 執行個體清單中,按一下 VM 名稱,即可查看 VM 的「Details」頁面。
找到頁面中的「API 與身分識別管理」專區。服務帳戶會列為「Service account」欄位的值。
如要瞭解如何設定授予服務帳戶的角色,請參閱「驗證及修改現有服務帳戶的角色」。
健康狀態檢查可偵測由 Ops Agent 執行的 API 權限錯誤。
設定無效
如果設定無效,嘗試重新啟動代理程式服務時,可能會看到以下錯誤:
Linux
$ sudo service google-cloud-ops-agent restart \ && sudo service google-cloud-ops-agent status ● google-cloud-ops-agent-fluent-bit.service - Google Cloud Ops Agent - Logging Agent Loaded: loaded (/usr/lib/systemd/system/google-cloud-ops-agent-fluent-bit.service; static; vendor preset: disabled) Drop-In: /usr/lib/systemd/system/google-cloud-ops-agent-fluent-bit.service.d └─directories.conf Active: failed (Result: exit-code) since Wed 2021-06-30 22:21:08 UTC; 2s ago Process: 1141421 ExecStart=/opt/google-cloud-ops-agent/subagents/fluent-bit/bin/fluent-bit --config ${RUNTIME_DIRECTORY}/fluent_bit_main.conf --parser ${RUNTIME_DIRECTORY}/fluent_bit_parser.conf --log_> Process: 1141847 ExecStartPre=/opt/google-cloud-ops-agent/libexec/google_cloud_ops_agent_engine -service=fluentbit -in /etc/google-cloud-ops-agent/config.yaml -logs ${LOGS_DIRECTORY} -state ${STATE_DIR> Main PID: 1141421 (code=exited, status=0/SUCCESS) Jun 30 22:21:08 centos8-2 systemd[1]: google-cloud-ops-agent-fluent-bit.service: Control process exited, code=exited status=1 Jun 30 22:21:08 centos8-2 systemd[1]: google-cloud-ops-agent-fluent-bit.service: Failed with result 'exit-code'. Jun 30 22:21:08 centos8-2 systemd[1]: Failed to start Google Cloud Ops Agent - Logging Agent. Jun 30 22:21:08 centos8-2 systemd[1]: google-cloud-ops-agent-fluent-bit.service: Service RestartSec=100ms expired, scheduling restart. Jun 30 22:21:08 centos8-2 systemd[1]: google-cloud-ops-agent-fluent-bit.service: Scheduled restart job, restart counter is at 5. Jun 30 22:21:08 centos8-2 systemd[1]: Stopped Google Cloud Ops Agent - Logging Agent. Jun 30 22:21:08 centos8-2 systemd[1]: google-cloud-ops-agent-fluent-bit.service: Start request repeated too quickly. Jun 30 22:21:08 centos8-2 systemd[1]: google-cloud-ops-agent-fluent-bit.service: Failed with result 'exit-code'. Jun 30 22:21:08 centos8-2 systemd[1]: Failed to start Google Cloud Ops Agent - Logging Agent.
使用 journalctl
取得確切的錯誤訊息:
sudo journalctl -xe | grep "google_cloud_ops_agent_engine"
您可能會看到類似以下的訊息:
Jun 30 22:00:26 centos8-2 google_cloud_ops_agent_engine[1141491]: 2021/06/30 22:00:26 the agent config file is not valid YAML. detailed error: yaml: line 21: did not find expected key
Windows
failed to generate config files: can't parse configuration: yaml: line 20: could not find expected ':'
如要修正錯誤,請修正無效的設定並重新啟動代理程式。如需參考資料,請參閱「設定作業套件代理程式」指南。
代理程式當機,且報告提到 NVIDIA
您嘗試在 Compute Engine VM 上執行 Ops Agent,但 VM 已連結 GPU。代理程式停止運作,且輸出內容提及 NVIDIA。
這是 Ops Agent 2.39.0 和 2.40.0 版的已知問題。如要緩解這個問題,請安裝 2.38.0 以上版本的作業套件代理程式。Google Cloud 主控台中的狀態資訊有誤
Google Cloud 控制台會在各種資訊主頁中,回報 Compute Engine VM 上代理程式的狀態資訊,例如 Cloud Monitoring 中的「VM 執行個體」資訊主頁。如果這項資訊與您預期的結果不符,原因可能只是系統在處理設定變更時,導致延遲。不過,非預期的資訊也可能表示服務代理無法正常運作。
Google Cloud 控制台回報已安裝的代理程式未偵測到
代理程式必須執行並擷取資料, Google Cloud 主控台才能辨識代理程式。如果您已安裝代理程式,但控制台狀態仍顯示「未偵測到」,表示代理程式並未執行,或執行中但未擷取資料。如要瞭解詳情,請參考下列資源:
Google Cloud 主控台回報已移除的代理程式已安裝
卸除代理程式後, Google Cloud 主控台可能需要最多一小時的時間才能回報這項變更。