0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

GCPのops-agentを使ってdocker composeのコンテナのログをLoggingに飛ばす

Posted at

前提

  • Google Compute EngineのVMを利用
  • VM作成時にアクセススコープを デフォルトのアクセス権を許可 に指定
  • Debianのイメージを使用

手順

ops-agent のインストール

curl -sSO https://dl.google.com/cloudagents/add-google-cloud-ops-agent-repo.sh
sudo bash add-google-cloud-ops-agent-repo.sh --also-install

config.yml 編集

sudo vim /etc/google-cloud-ops-agent/config.yaml
logging:
  receivers:
    fluentbit:
      type: fluent_forward
      listen_host: 127.0.0.1
      listen_port: 24224
  service:
    pipelines:
      default_pipeline:
        receivers: []
      app_pipeline:
        receivers: [fluentbit]
        processors: [app_processor]
  processors:
    app_processor:
      type: parse_json

config.yml 反映

sudo service google-cloud-ops-agent restart

docker-compose.yml のサービスに logging で fluend のホストとポートを指定する。

version: '3.6'

services:
  app:
    logging:
      driver: "fluentd"
      options:
        fluentd-address: "localhost:24224"
        tag: "app01"

コンテナ再起動

docker-compose up -d

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?