すべてのプロダクト
Search
ドキュメントセンター

Container Service for Kubernetes:ノードのsystemdジャーナルログの収集

最終更新日:Nov 14, 2024

Linuxでは、systemdは起動後のすべてのサービスの管理を担当する初期化システムおよびサービスマネージャーです。 systemdの重要な部分は、システムログを収集して保存するJournalです。 Kubernetes環境では、kubeletやオペレーティングシステムからのログなど、ノードの安定性に関する情報を取得するには、systemdジャーナルログのクエリと分析が不可欠です。 Container Service for Kubernetes (ACK) クラスターは、Simple Log Serviceと統合されます。 Logtailコンポーネントをインストールして、DaemonSetsを使用してログを収集できます。

課金

この機能を使用するには、ACKクラスターに関連する料金に加えて、Simple Log Serviceに関連する料金も発生します。 Simple Log Serviceは従量課金制で動作します。 詳細については、「Simple Log Service課金の概要」をご参照ください。

前提条件

手順1: AliyunLogConfigを使用して収集方法を設定する

AliyunLogConfigは、Simple Log Serviceに特化したカスタムリソース定義 (CRD) です。 AliyunLogConfigのYAMLファイルを使用して、logtail-dsのログ収集設定を管理する対応するカスタムリソース (CR) を作成できます。

次のサンプルコードでは、systemd-journal-log-configという名前のLogtail構成を例として使用し、クラスター内のすべてのノードの /logtail_host/var/log/journalディレクトリからsystemdジャーナルログを収集する方法を示します。

projectフィールドとlogstoreフィールドに既存のプロジェクトとlogstoreを指定してデータを受信するか、システムに自動的に生成させることができます。

apiVersion: log.alibabacloud.com/v1alpha1
kind: AliyunLogConfig
metadata:
  # The resource name must be unique within the current ACK cluster.
  name: systemd-journal-log-config
  namespace: kube-system
spec:
  # Specify the name of the project to which the collected data is reported. Default value is k8s-log-<your_cluster_id>. Custom names are also supported. If the specified Project does not exist, the system will automatically create it.
  project: k8s-log-<your_cluster_id>
  # Specify the name of the Logstore to which the collected data is reported. If the specified Logstore does not exist, the system will automatically create it.
  logstore: systemd-journal-log
  # The Logtail configuration.
  logtailConfig:
    # Specify the type of the data source. To collect text logs, set the value to file.
    inputType: plugin
    # Specify the name of the Logtail collection configuration.
    configName: systemd-journal-log-config
    inputDetail:
      plugin:
        inputs:
        - detail:
            JournalPaths:
            - "/logtail_host/var/log/journal"
            Kernel: true
            ParsePriority: true
            ParseSyslogFacility: true
          type: service_journal

ステップ2: 収集したデータの照会と分析

コレクションを設定した後、Simple log Serviceコンソールにログインして、指定されたプロジェクトおよびLogstore内のすべてのノードからsystemdジャーナルログを照会します。 詳細については、「ログの照会と分析」をご参照ください。

関連ドキュメント

logtail-dsは、バイナリファイルから直接systemdジャーナルログを収集できます。 詳細については、「systemdジャーナルログの収集」をご参照ください。