본문 바로가기
GCP

GCE(Google Compute Engine) syslog를 GCP Logging으로 전송

by misankim 2023. 4. 29.

GCE(Google Compute Engine) syslog를 GCP Logging으로 전송

 

로깅 에이전트 개요

https://cloud.google.com/logging/docs/agent/logging?hl=ko

 

로깅 애이전트 지원되는 운영체제, 지원되는 환경

https://cloud.google.com/logging/docs/agent/logging?hl=ko#supported_operating_systems

 

기본 Logging 에이전트 로그(수집하는 대상 로그)

https://cloud.google.com/logging/docs/agent/default-logs?hl=ko

 

 

# 로깅 에이전트 설치

 

https://cloud.google.com/logging/docs/agent/logging/installation?hl=ko#install-latest-version

 

curl -sSO https://dl.google.com/cloudagents/add-logging-agent-repo.sh

sudo bash add-logging-agent-repo.sh --also-install

 

로깅 에이전트 재시작

sudo service google-fluentd restart

 

부팅 시 자동 실행 확인

chkconfig --list google-fluentd

 

 

# 타사 애플리케이션 로그 입력 구성

 

https://cloud.google.com/logging/docs/agent/logging/configuration?hl=ko#third-party_application_log_input_configuration

 

cd /etc/google-fluentd/config.d/

[root@was config.d]# cat apache.conf
<source>
  @type tail
  format none
  path /var/log/apache*/access.log,/var/log/apache*/access_log,/var/log/httpd/access.log,/var/log/httpd/access_log
  pos_file /var/lib/google-fluentd/pos/apache-access.pos
  read_from_head true
  tag apache-access
</source>

<source>
  @type tail
  format none
  path /var/log/apache*/error.log,/var/log/apache*/error_log,/var/log/httpd/error.log,/var/log/httpd/error_log
  pos_file /var/lib/google-fluentd/pos/apache-error.pos
  read_from_head true
  tag apache-error
</source>