grasys blog

Google Stackdriver Logging Compute Engine セットアップ編 2016年10月

こんにちはgrasys長谷川です。

Monitoringを書いたので今日はLoggingを!

最近みんなblog書くの飽きてきたみたいだけどオレはもうちょいがんばるw

Logglyとかに似てるサービスですね

Documentはここ -> Stackdriver Logging

Instance作成

ParameterValue
INSTANCE_NAMEインスタンスの名前になります。適当な名前を
IMAGEgcloud compute images listでCentOS系を選んで下さい。
–scopesデフォルトの設定を入れてます。
gcloud compute instances create [INSTANCE_NAME] \
  --zone "us-west1-b" \
  --machine-type "g1-small" \
  --network "default" \
  --maintenance-policy "MIGRATE" \
  --scopes default="https://www.googleapis.com/auth/logging.write","https://www.googleapis.com/auth/monitoring.write","https://www.googleapis.com/auth/servicecontrol","https://www.googleapis.com/auth/service.management.readonly","https://www.googleapis.com/auth/devstorage.read_only" \
  --image [IMAGE] \
  --boot-disk-size "10" \
  --boot-disk-type "pd-standard" \
  --boot-disk-device-name [INSTANCE_NAME]

credentialは説明がめんどいので、今回はscopeで対応します。
Cloud Logging APIを有効にしてInstanceを構成して下さい。

Stackdriver Logging

google-fluentdのInstall

Installing the Logging Agent

curl -sSO https://dl.google.com/cloudagents/install-logging-agent.sh
sudo bash install-logging-agent.sh

Directory Tree

$ tree -L 2 /opt/google-fluentd
/opt/google-fluentd
├── bin
├── embedded
│   ├── bin
│   ├── include
│   ├── info
│   ├── lib
│   ├── man
│   ├── share
│   └── ssl
├── etc
│   ├── google-fluentd
│   └── init.d
├── LICENSE
├── LICENSES
│   ├── cacerts-README.md
│   ├── config_guess-config.guess
│   ├── config_guess-config.sub
│   ├── libedit-COPYING
│   ├── libffi-LICENSE
│   ├── libiconv-COPYING.LIB
│   ├── liblzma-COPYING
│   ├── libtool-COPYING
│   ├── libxml2-COPYING
│   ├── libxslt-COPYING
│   ├── libyaml-LICENSE
│   ├── makedepend-COPYING
│   ├── ncurses-ncurses.faq.html
│   ├── ncurses-ncurses-license.html
│   ├── nokogiri-LICENSE.txt
│   ├── openssl-LICENSE
│   ├── pkg-config-lite-COPYING
│   ├── rubygems-LICENSE.txt
│   ├── util-macros-COPYING
│   ├── xproto-COPYING
│   └── zlib-README
├── usr
│   ├── bin
│   └── sbin
├── version-manifest.json
└── version-manifest.txt

16 directories, 24 files

fluentdがベースになってます。

中身も基本的にはfluentdと一緒なのでlogのpath追加したい場合も
任意にconfigを追加すれば対応可能です。

tagを付けるのを忘れずに

tagがStackdriver Loggingの画面上のLogの名前になります。

config directoryは以下 /etc/google-fluentd/config.d

予め一般的な設定がそこそこ入ってたりします。

$ ls -1 /etc/google-fluentd/config.d/
apache.conf
cassandra.conf
chef.conf
forward.conf
gitlab.conf
jenkins.conf
jetty.conf
joomla.conf
magento.conf
mediawiki.conf
memcached.conf
mongodb.conf
mysql.conf
nginx.conf
postgresql.conf
puppet.conf
puppet-enterprise.conf
rabbitmq.conf
redis.conf
redmine.conf
salt.conf
solr.conf
sugarcrm.conf
syslog.conf
syslog_endpoint.conf
tomcat.conf
zookeeper.conf

forward.confはStackdriver Error Reportingに利用されます。

まだこれからちょこちょこ変わっちゃったりすると思いますが・・・


株式会社grasys(グラシス)は、技術が好きで一緒に夢中になれる仲間を募集しています。

grasysは、大規模・高負荷・高集積・高密度なシステムを多く扱っているITインフラの会社です。Google Cloud (GCP)、Amazon Web Services (AWS)、Microsoft Azureの最先端技術を活用してクラウドインフラやデータ分析基盤など、ITシステムの重要な基盤を設計・構築し、改善を続けながら運用しています。

お客様の課題解決をしながら技術を広げたい方、攻めのインフラ技術を習得したい方、とことん技術を追求したい方にとって素晴らしい環境が、grasysにはあります。
お気軽にご連絡ください。

株式会社grasys | 採用情報


採用情報
お問い合わせ