把 log 加入 GCP cloud logging
  • 719 views,
  • 2023-08-21,
  • 上傳者: Kuann Hung,
  •  0
當系統越來越龐大複雜,這時候不管是 access log 或是 audit log 就變得相對重要。在雲端分散式系統中,如何整合 log 也變得有更大的需求。以下就來介紹說明如何透過 Stackdriver 把資料收入 GCP 的 Cloud Logging service 中
 
步驟
1.
先安裝相關的 agent
 
CentOS
curl -sSO https://dl.google.com/cloudagents/add-logging-agent-repo.sh
sudo bash add-logging-agent-repo.sh
sudo yum install google-fluentd
2.
啟用 Stackdriver agent
sudo systemctl start google-fluentd
sudo systemctl enable google-fluentd
 
3.
編輯相關設定
 
/etc/google-fluentd/config.d/td-agent.conf
vi /etc/google-fluentd/config.d/td-agent.conf
 
可以在裡面加上你要監控的 log 目錄
<source>
  @type tail
  format apache
  path /var/log/apache2/access.log
  tag apache-access
</source>

<source>
  @type tail
  format apache
  path /var/log/apache2/error.log
  tag apache-error
</source>
 
Facebook 討論區載入中...
資料夾 :
發表時間 :
2023-08-21 08:57:38
觀看數 :
719
發表人 :
Kuann Hung
部門 :
老洪的 IT 學習系統
QR Code :