---
title: "Google Stackdriver Logging Compute Engine セットアップ編 2016年10月 | grasys blog"
url: "https://blog.grasys.io/post/yusukeh/stackdriver_logging/"
description: "こんにちはgrasys長谷川です。 Monitoringを書いたので今日はLoggingを！ 最近みんなblog書くの飽きてきたみたいだけどオレはもうちょいがんばるｗ Logglyとかに似てるサービスですね Documentはここ - Stackdriver Logging Instance作成 Parameter…"
---

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

-   ![](/_astro/noicon.CTHOhNiB_1HMs6A.webp)[yusukeh](/authors/yusukeh/)
-   公開日：2016年10月12日
-   カテゴリー：[Tech](/categories/tech/)
-   タグ：[#Compute Engine](/tags/compute-engine/)[#Google Cloud](/tags/google-cloud/)[#Cloud Logging](/tags/cloud-logging/)[#stackdriver](/tags/stackdriver/)

![Google Stackdriver Logging Compute Engine セットアップ編 2016年10月](/_astro/ogp.CafhM1h__VLfJg.webp)

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

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

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

![Google Stackdriver Logging Compute Engine セットアップ編 2016年10月の画面](/_astro/01-stackdriver_logging-1024x500-f6c15a38.DwvWF-o4_Z2sXpzB.webp)

[Loggly](https://www.loggly.com/)とかに似てるサービスですね

Documentはここ -> [Stackdriver Logging](https://cloud.google.com/logging/docs/)

## Instance作成

| Parameter | Value |
| --- | --- |
| INSTANCE_NAME | インスタンスの名前になります。適当な名前を |
| IMAGE | gcloud compute images listでCentOS系を選んで下さい。 |
| –scopes | デフォルトの設定を入れてます。 |

Plain textcontent\_copy

```
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](https://cloud.google.com/logging/docs/agent/installation)

Plain textcontent\_copy

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

## Directory Tree

Plain textcontent\_copy

```
$ 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](http://www.fluentd.org/)がベースになってます。

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

**tagを付けるのを忘れずに**

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

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

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

Plain textcontent\_copy

```
$ 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に利用されます。

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

## この記事を書いた人

[![](/_astro/yusukeh.BvUd2yKE_1mQ6Fp.webp)](/authors/yusukeh/)

### [yusukeh](/authors/yusukeh/)

Fly high. Think deep. Move fast. Go far.🦅

-   [X](https://x.com/yusukeh "X")
-   [GitHub](https://github.com/yusukeh "GitHub")
-   [Medium](https://medium.com/@yusukeh "Medium")
-   [Facebook](https://www.facebook.com/yusuke.exzm "Facebook")
-   [Instagram](https://www.instagram.com/yusukehasegawa/ "Instagram")
-   [LinkedIn](https://www.linkedin.com/in/hasegawa-yusuke-091b4164/ "LinkedIn")

[プロフィールと記事一覧](/authors/yusukeh/)
