GKE - コントロール プレーン アプリケーションのログとメトリクスの収集
このページでは、GKE - コントロール プレーン 用 Sumo アプリケーションのログとメトリクス収集の設定手順を説明します。
収集プロセスの概要
Sumo Logic Kubernetes アプリケーションをインストールしたら、Hosted Collector と HTTP Source を設定して、Kubernetes 接続を確立します。そして、Google Cloud Platform (GCP) サービス コレクションの主要コンポーネント (Google Stackdriver、Google Cloud Pub/Sub など) を設定します。最後に、メトリクスの収集を設定します。
GCP 統合では、Google Logging が GCP サービスからログを収集します。パイプラインを設定すると、ログが Google Pub/Sub トピックにパブリッシュされます。そのトピックをサブスクライブしている、Hosted Collector 上の Sumo Logic GCP Source は、ログを Sumo Logic に取り込みます。
設定プロセスには以下の作業が含まれます。
- Hosted Collector で GCP Source を設定します。Source の HTTP URL を取得し、Google Cloud コンソールを使用して URL を検証済みドメインとして登録します。
- Google Pub/Sub でトピックを作成し、そのトピックへの GCP Source URL をサブスクライブします。
- Google Logging からの GCP ログのエクスポートを作成します。ログをエクスポートするには、エクスポートしたいログ エントリを選択するためのフィルタを作成し、宛先として Pub/Sub を選択します。フィルターと宛先は、シンクと呼ばれるオブジェクトに格納されます。
ステップ 1.Kubernetes アプリケーションをセットアップしてインストールする
Sumo Logic Kubernetes アプリケーションは、Kubernetes ワーカー ノードの管理とモニタリングを行うサービスを提供します。GKE アプリケーションの収集を設定する前に、Kubernetes アプリケーションの収集をセットアップしてアプリケーションをインストールする必要があります。このプロセスでは、ログとメトリクスの収集を設定します。
Stackdriver サポート オプション
GKE クラスタを作成する場合は、2 つの Stackdriver サポート オプションがあります。次のいずれかを選択してください。
- Legacy Stackdriver のサポート。
- Stackdriver Kubernetes Engine Monitoring のサポート。
どちらのオプションを選んでも構いません。GKE 用 Sumo Logic アプリケーションは、Legacy Stackdriver と Stackdriver Monitoring の両方のログをサポートします。
アプリケーションのインストール
Kubernetes アプリケーションをセットアップしてインストールするにはこのドキュメントの手順に従ってください。
ステップ 2.Google Cloud Platform Source の設定
GCP Source は、Google Pub/Sub からログデータを受け取ります。GCP Source は、Google Pub/Sub からのデータとして形式化されたログ データにのみ使用できます。
Google Platform Source を設定するには、このドキュメントの手順に従ってください。
ステップ 3.GCP 用の Pub/Sub トピックの設定
Pub/Sub を設定したら、Stackdriver から Pub/Sub にデータをエクスポートできます。
GCP 用の Pub/Sub トピックを設定するには、このドキュメントの手順に従ってください。
ステップ 4.Stackdriver からの Google Kubernetes Engine ログのエクスポートの作成
このセクションでは、Stackdriver から Google Kubernetes Engine ログのエクスポートの作成作業を順を追って説明します。
Stackdriver からの GKE ログのエクスポートを作成するには、次の手順を実行します。
- GCP アカウントにログインし、[Logging (ログ)] に移動して、ポップアップ メニューから [Exports (エクスポート)] を選択します。
- [Create Export (エクスポートの作成)] をクリックします。
- GCP サービスを選択してログを絞り込みます。
GKE には Stackdriver の管理サポートが含まれています。クラスタ用の GKE バージョンとサポート オプションを選択すると、Stackdriver のサポートが自動的にインストールまたは更新されます。3 つのサポート オプションがあります。これらのオプションは、すべての GKE バージョンで提供されており、新規クラスタの作成時と既存クラスタの更新時に使用できます。
- Legacy Stackdriver サポート。
- Stackdriver Kubernetes Engine Monitoring のサポート。
- Stackdriver のサポートなし。
選択したオプションに応じて、sink を作成する際の “GCP サービス” の名前が、次の表に示すようにマッピングに従って自動的に変更されます。
Legacy Stackdriver | Stackdriver Kubernetes Engine Monitoring | |
---|---|---|
GKE Cluster Operations | ![]() |
![]() |
Kubernetes Cluster | ![]() |
![]() |
Kubernetes Node | ![]() |
|
Kubernetes Pod | ![]() |
-
セットアップする GCP サービスを決定して、次のいずれかの方法で sink を作成作成します。
-
Legacy Stackdriver の場合は、次のフィルタを使用します。reSource.type="gke_cluster" OR reSource.type="k8s_cluster"
-
Stackdriver Monitoring の場合は、次の高度なフィルタを使用します。
-
resource.type="gke_cluster" OR resource.type="k8s_cluster" OR resource.type="k8s_node" OR resource.type="k8s_pod
-
右側の [Edit Export (エクスポートの編集)] ウィンドウで次の操作を実行します。
-
Sink 名を入力します。たとえば、"gce-vm-instance" です。
-
[Sink Service (Sink サービス)] として [Cloud Pub/Sub] を選択します。
-
[Sink Destination (Sink ターゲット)] を「Google Cloud Platform Source」の手順で作成した Pub/Sub トピックに設定します。たとえば、"pub-sub-logs" です。
-
[Create Sink (Sink の作成)] をクリックします。
-
すべてのサービスで上の手順を繰り返します。
- デフォルトでは、GCP ログは Stackdriver 内に保存されますが、このドキュメントで説明する手順に従って、GCP ログを除外するように Stackdriver を設定することもできます。この設定により、上記の Sumo Logic へのエクスポートに影響が及ぶことはありません。Stackdriver のログを除外する方法については、この GCP ドキュメントの手順に従ってください。
ログ メッセージのサンプル
StackDriver Monitoring - Container StdErr (StackDriver Monitoring - コンテナ StdErr)
{ "message":{ "attributes":{ "logging.googleapis.com/timestamp":"2019-06-26T10:41:00.394447795Z" }, "data":{ "insertId":"qmuyjp0a5yrmvuyzy", "labels":{ "k8s-pod/app":"prometheus", "k8s-pod/controller-revision-hash":"prometheus-prometheus-operator-prometheus-67f77458d4", "k8s-pod/prometheus":"prometheus-operator-prometheus", "k8s-pod/statefulset_kubernetes_io/pod-name":"prometheus-prometheus-operator-prometheus-0" }, "logName":"projects/product-sandbox-1/logs/stderr", "receiveTimestamp":"2019-06-26T10:41:05.973133299Z", "resource":{ "labels":{ "cluster_name":"arun-gke-stackdriver-engine-monitoring", "container_name":"prometheus", "location":"us-central1-a", "namespace_name":"sumologic", "pod_name":"prometheus-prometheus-operator-prometheus-0", "project_id":"product-sandbox-1" }, "type":"k8s_container" }, "severity":"ERROR", "textPayload":"ts=2019-06-26T10:41:00.394Z caller=dedupe.go:111 component=remote level=info queue=13:http://fluentd:9888/prometheus.metrics.apiserver msg=\"Remote storage resharding\" from=6 to=3\n", "timestamp":"2019-06-26T10:41:00.394447795Z" }, "messageId":"597120419207003", "message_id":"597120419207003", "publishTime":"2019-06-26T10:41:06.382Z", "publish_time":"2019-06-26T10:41:06.382Z" }, "subscription":"projects/product-sandbox-1/subscriptions/sumo_gke_stackdriver" }
StackDriver Monitoring - Container StdOut (StackDriver Monitoring - コンテナ StdOut)
{ "message":{ "attributes":{ "logging.googleapis.com/timestamp":"2019-06-26T10:44:04.40824208Z" }, "data":{ "insertId":"hz9rs3tndyceb4rvh", "labels":{ "k8s-pod/component":"test-logger", "k8s-pod/pod-template-hash":"7896bcb5cd" }, "logName":"projects/product-sandbox-1/logs/stdout", "receiveTimestamp":"2019-06-26T10:44:06.456680433Z", "resource":{ "labels":{ "cluster_name":"arun-gke-stackdriver-engine-monitoring", "container_name":"test-logger", "location":"us-central1-a", "namespace_name":"default", "pod_name":"test-logger-7896bcb5cd-954mz", "project_id":"product-sandbox-1" }, "type":"k8s_container" }, "severity":"INFO", "textPayload":"Processing credit card 1234 5678 9012 3456\n", "timestamp":"2019-06-26T10:44:04.40824208Z" }, "messageId":"597120030247162", "message_id":"597120030247162", "publishTime":"2019-06-26T10:44:06.965Z", "publish_time":"2019-06-26T10:44:06.965Z" }, "subscription":"projects/product-sandbox-1/subscriptions/sumo_gke_stackdriver" }
StackDriver Monitoring - Events (StackDriver Monitoring - イベント)
{ "message":{ "attributes":{ "logging.googleapis.com/timestamp":"2019-06-26T10:38:14Z" }, "data":{ "insertId":"1o05pug1iym1ef", "jsonPayload":{ "apiVersion":"v1", "involvedObject":{ "apiVersion":"v1", "kind":"Pod", "name":"mysql-fc99db7b8-jv7tl", "namespace":"robot-shop", "resourceVersion":"5625122", "uid":"5548f14c-8e79-11e9-bbfd-42010a8002a8" }, "kind":"Event", "message":"0/3 nodes are available: 3 Insufficient cpu.", "metadata":{ "creationTimestamp":"2019-06-23T21:57:27Z", "name":"mysql-fc99db7b8-jv7tl.15aaf2ad63dddd2c", "namespace":"robot-shop", "resourceVersion":"50268", "selfLink":"/api/v1/namespaces/robot-shop/events/mysql-fc99db7b8-jv7tl.15aaf2ad63dddd2c", "uid":"e3de27c7-9601-11e9-870d-42010a80023c" }, "reason":"FailedScheduling", "source":{ "component":"default-scheduler" }, "type":"Warning" }, "logName":"projects/product-sandbox-1/logs/events", "receiveTimestamp":"2019-06-26T10:38:19.792891713Z", "resource":{ "labels":{ "cluster_name":"arun-gke-stackdriver-engine-monitoring", "location":"us-central1-a", "namespace_name":"robot-shop", "pod_name":"mysql-fc99db7b8-jv7tl", "project_id":"product-sandbox-1" }, "type":"k8s_pod" }, "severity":"WARNING", "timestamp":"2019-06-26T10:38:14Z" }, "messageId":"597107305873932", "message_id":"597107305873932", "publishTime":"2019-06-26T10:38:20.474Z", "publish_time":"2019-06-26T10:38:20.474Z" }, "subscription":"projects/product-sandbox-1/subscriptions/sumo_gke_stackdriver" }
Legacy StackDriver - Container StdErr (Legacy StackDriver - コンテナ StdErr)
{ "message":{ "attributes":{ "logging.googleapis.com/timestamp":"2019-06-26T10:47:13.128751259Z" }, "data":{ "insertId":"1cakep6g1ncgxlq", "labels":{ "compute.googleapis.com/resource_name":"fluentd-gcp-v3.2.0-5j8t8", "container.googleapis.com/namespace_name":"sumologic", "container.googleapis.com/pod_name":"prometheus-prometheus-operator-prometheus-0", "container.googleapis.com/stream":"stderr" }, "logName":"projects/product-sandbox-1/logs/prometheus", "receiveTimestamp":"2019-06-26T10:47:19.525038772Z", "resource":{ "labels":{ "cluster_name":"arun-gke-cluster", "container_name":"prometheus", "instance_id":"3947999507639860837", "namespace_id":"sumologic", "pod_id":"prometheus-prometheus-operator-prometheus-0", "project_id":"product-sandbox-1", "zone":"us-central1-a" }, "type":"container" }, "severity":"ERROR", "textPayload":"ts=2019-06-26T10:47:13.128Z caller=dedupe.go:111 component=remote level=info queue=19:http://fluentd:9888/prometheus.metrics.container msg=\"Remote storage resharding\" from=373 to=92\n", "timestamp":"2019-06-26T10:47:13.128751259Z" }, "messageId":"597119793276049", "message_id":"597119793276049", "publishTime":"2019-06-26T10:47:20.275Z", "publish_time":"2019-06-26T10:47:20.275Z" }, "subscription":"projects/product-sandbox-1/subscriptions/gke_cluster" }
Legacy StackDriver - Container StdOut (Legacy StackDriver - コンテナ StdOut)
{ "message":{ "attributes":{ "logging.googleapis.com/timestamp":"2019-06-26T10:47:36.932520043Z" }, "data":{ "insertId":"qczw0afzu9akl", "labels":{ "compute.googleapis.com/resource_name":"fluentd-gcp-v3.2.0-vkzt5", "container.googleapis.com/namespace_name":"default", "container.googleapis.com/pod_name":"test-logger-76d458db56-gl4fq", "container.googleapis.com/stream":"stdout" }, "logName":"projects/product-sandbox-1/logs/test-logger", "receiveTimestamp":"2019-06-26T10:47:40.192057183Z", "resource":{ "labels":{ "cluster_name":"arun-gke-cluster", "container_name":"test-logger", "instance_id":"8083082308129291877", "namespace_id":"default", "pod_id":"test-logger-76d458db56-gl4fq", "project_id":"product-sandbox-1", "zone":"us-central1-a" }, "type":"container" }, "severity":"INFO", "textPayload":"Processing credit card 1234 5678 9012 3456\n", "timestamp":"2019-06-26T10:47:36.932520043Z" }, "messageId":"597121135964578", "message_id":"597121135964578", "publishTime":"2019-06-26T10:47:40.423Z", "publish_time":"2019-06-26T10:47:40.423Z" }, "subscription":"projects/product-sandbox-1/subscriptions/gke_cluster" }
Legacy StackDriver - Events (Legacy StackDriver - イベント)
{ "message":{ "attributes":{ "logging.googleapis.com/timestamp":"2019-06-26T10:45:28Z" }, "data":{ "insertId":"12l15ytg1iuthzk", "jsonPayload":{ "apiVersion":"v1", "involvedObject":{ "apiVersion":"v1", "kind":"Pod", "name":"fluentd-594f98d6c8-jzpfs", "namespace":"sumologic", "resourceVersion":"1535338", "uid":"f8a6c405-8395-11e9-9642-42010a800109" }, "kind":"Event", "message":"MountVolume.SetUp failed for volume \"fluentd-token-sr2xf\" : secrets \"fluentd-token-sr2xf\" not found", "metadata":{ "creationTimestamp":"2019-06-04T09:53:35Z", "name":"fluentd-594f98d6c8-jzpfs.15a4f62662893b2f", "namespace":"sumologic", "resourceVersion":"132802", "selfLink":"/api/v1/namespaces/sumologic/events/fluentd-594f98d6c8-jzpfs.15a4f62662893b2f", "uid":"9ebb2fed-86ae-11e9-bcca-42010a800109" }, "reason":"FailedMount", "source":{ "component":"kubelet", "host":"gke-arun-gke-cluster-default-pool-4b292970-g7qt" }, "type":"Warning" }, "logName":"projects/product-sandbox-1/logs/events", "receiveTimestamp":"2019-06-26T10:45:33.816643511Z", "resource":{ "labels":{ "cluster_name":"arun-gke-cluster", "location":"us-central1-a", "project_id":"product-sandbox-1" }, "type":"gke_cluster" }, "severity":"WARNING", "timestamp":"2019-06-26T10:45:28Z" }, "messageId":"597115129096918", "message_id":"597115129096918", "publishTime":"2019-06-26T10:45:34.192Z", "publish_time":"2019-06-26T10:45:34.192Z" }, "subscription":"projects/product-sandbox-1/subscriptions/gke_cluster" }
クエリのサンプル
Error Stream - Stackdriver Monitoring (エラー ストリーム - Stackdriver Monitoring)
_source="GKE Cloud Logs - Stackdriver" error | parse regex "\"logName\":\"(?<log_name>[^\"]+)\"" | json field=_raw "message.data.jsonPayload.message" as message | json "message.data.resource.labels" as labels | json field=labels "project_id", "cluster_name" as project, cluster | json field=_raw "message.data.timestamp" as timestamp | count by timestamp, project, cluster,log_name, message
Created ReSources by Node Over Time - Legacy Stackdriver (一定期間にわたるノード別の作成済みリソース - Legacy Stackdriver)
_sourceCategory = "GKE Cloud Logs - Legacy Stackdriver" logName reason host "\"type\":\"gke_cluster\"" "\"reason\":\"Created\"" | parse regex "\"logName\":\"(?<log_name>[^\"]+)\"" | where log_name matches "projects/*/logs/events" | json "message.data.resource.labels", "message.data.jsonPayload.source.host" as labels, node | json field=labels "project_id", "cluster_name" as project, cluster | timeslice 1h | count as eventCount by _timeslice, node, cluster, project | transpose row _timeslice column node, cluster, project | fillmissing timeslice(1h)