Google Kubernetes Engine のログの収集
このページでは、Google Cloud Platform (GCP) サービスからログを取得する Sumo パイプラインを説明し、Google Kubernetes Engine からログを収集する手順を紹介します。
Stackdriver からの Google Kubernetes Engine ログのエクスポートの作成
- [Logging (ログ)] に移動して [Exports (エクスポート)] をクリックします。
- [Create Export (エクスポートの作成)] をクリックします。
-
GCP サービスを選択してログを絞り込みます。シンクを作成するための推奨 GCP サービスは「GKE Cluster」です。これにより、サービスのログを Sumo Logic に送信します。右側の [Edit Export (エクスポートの編集)] ウィンドウで次の操作を実行します。右側の [Edit Export (エクスポートの編集)] ウィンドウで次の操作を実行します。
- Sink 名を入力します。たとえば、"gce-vm-instance" です。
- [Sink Service (Sink サービス)] として [Cloud Pub/Sub] を選択します。
- [Sink Destination (Sink ターゲット)] を「Google Cloud Platform ソース」の手順で作成した Pub/Sub トピックに設定します。たとえば、"pub-sub-logs" です。
- [Create Sink (Sink の作成)] をクリックします。
クエリのサンプル
一定期間にわたって作成されたリソース
_sourceCategory=*gcp* logName resource "\"type\":\"gke_cluster\"" | parse regex "\"logName\":\"(?<log_name>[^\"]+)\"" | where log_name matches "projects/*/logs/events" | json "message.data.resource.labels" as labels | json field=labels "project_id", "cluster_name" as project, cluster | timeslice 1h | count as events by _timeslice, cluster, project | transpose row _timeslice column cluster, project