Pre-General Availability (一般提供前)バージョン: 2026-02-26

7 PrometheusによるBesuメトリックのモニター

Prometheusおよびkube-prometheus-stackを使用して、Kubernetesクラスタで実行されているBesuノードからメトリックを取得できます。

監視をインストールするには、Helm、kube-prometheus-stack、およびConsensys/quorum-kubernetesリポジトリに保持されている事前定義済の値ファイル(monitoring.yml)を使用します。このシナリオでは、PrometheusはIstioサービス・メッシュ内で動作し、相互TLSを介してメトリックを安全にスクレイプします。kube-prometheus-stackパッケージは、次のソフトウェアをインストールします。
  • Prometheus
  • Prometheusオペレータ
  • Grafana
  • アラート・マネージャ
  • 標準Kubernetesエクスポータ

kube-prometheusスタック・アーキテクチャでは、PrometheusはServiceMonitorというKubernetesカスタム・リソースを使用してスクレイプ・ターゲットを検出します。このリソースは、スクレイプするサービス、メトリックを公開するポートとパス、およびTLSと相互TLSの構成を定義します。Helmを使用してkube-prometheus-stackをインストールすると、kube-state-metricsやnode-exporterなどのコンポーネントのServiceMonitorリソースが自動的に作成されます。ただし、Oracle Blockchain Platform Enterprise Edition for Hyperledger Besuメトリックをスクレイプするには、独自のServiceMonitorリソースを作成および管理する必要があります。

次の前提条件をインストールします。
  • Helm v3.x。次のコマンドを実行して、Helmバージョンを確認できます。
    helm version
  • kubectl
また、Kubernetesクラスタへのコマンドライン・アクセスも必要です。詳細は、Oracle Kubernetes Engineに接続を参照してください。
  1. Besuと互換性のあるmonitoring.ymlファイルを使用してkube-prometheus-stackをインストールします。
    1. 次のコマンドを入力して、ファイルをダウンロードします。monitoring.ymlファイルは、Consensys/quorum-kubernetesリポジトリに保持されます。
      curl -o monitoring.yml \ 
      https://raw.githubusercontent.com/Consensys/quorum-kubernetes/master/helm/values/monitoring.yml 
    2. 必要に応じて、デプロイメントの前に、Grafana管理者パスワードを更新し、monitoring.ymlでアラート受信者(電子メールやSlackなど)を構成します。
    3. まだ存在しない場合は、PrometheusコミュニティHelmリポジトリを追加します
      helm repo add prometheus-community https://prometheus-community.github.io/helm-charts 
      helm repo update 
    4. 監視専用のネームスペースに監視スタックをインストールします。次のコマンドでは、ネームスペースはモニタリングと呼ばれます。
      helm install monitoring prometheus-community/kube-prometheus-stack \ 
        --version 34.10.0 \ 
        --namespace monitoring \ 
        --create-namespace \ 
        --values monitoring.yml 
    5. デプロイメント・ステータスを確認するには、次のコマンドを実行します。
      kubectl get pods -n monitoring -l release=monitoring
    インストール・プロセスでは、モニタリング・スタックがmonitoringネームスペースにデプロイされ、Besu互換性のためにmonitoring.ymlファイルからオーバーライドが適用され、スタックに必要な標準のKubernets ServiceMonitorリソースが作成されます。
  2. Istio注釈をmonitoring.ymlファイルに追加して、PrometheusのIstioサイドカー・インジェクションを有効にします。Prometheusは、Istioメッシュを結合して、相互TLSを介してBesuエンドポイントをスクレイプする必要があります。monitoring.ymlファイルを開いて編集し、次のセクションを見つけます。
    prometheus: 
      prometheusSpec: 
        podMetadata:
    次のIstio注釈を追加します。
    prometheus: 
      prometheusSpec: 
        podMetadata: 
          annotations: 
            sidecar.istio.io/inject: "true" 
            sidecar.istio.io/userVolumeMount: | 
              [{"name": "istio-certs", "mountPath": "/etc/istio-certs", "readOnly": true}] 
            proxy.istio.io/config: | 
              proxyMetadata: 
                OUTPUT_CERTS: /etc/istio-certs 
              proxyMetadata.INBOUND_CAPTURE_PORTS: "" 
    これらの注釈は、PrometheusをIstioメッシュに追加し、ワークロードmTLS証明書を共有ボリュームに書き込むようにIstioを構成し、EnvoyがPrometheusインバウンド・トラフィックをインターセプトするのを防ぎ、Istioによって生成された証明書をPrometheusコンテナで使用できるようにします。
  3. ボリュームおよびボリューム・マウント情報をmonitoring.ymlファイルに追加して、Istio証明書をPrometheusにマウントします。monitoring.ymlファイルで次のテキストを見つけます。
    最初は空であるvolumesセクションを検索します。
        volumes: []
    次のテキストに示すように、volumesセクションを更新します。
        volumes: 
          - name: istio-certs 
            emptyDir: 
              medium: Memory 
     
    最初は空であるvolumeMountsセクションを検索します。
        volumeMounts: []
    次のテキストに示すように、volumeMountsセクションを更新します。
        volumeMounts: 
          - name: istio-certs 
            mountPath: /etc/prom-certs 
            readOnly: true
    Istioによって生成された証明書は、Prometheus (/etc/prom-certs/.)内で使用できるようになりました
  4. 更新された構成を適用します。
    1. 変更された値ファイルで既存のHelmリリースをアップグレードします。
      helm upgrade monitoring prometheus-community/kube-prometheus-stack \ 
        --namespace monitoring \ 
        --values monitoring.yml 
    2. Prometheusポッドが再起動され、Istioサイドカーで実行されていることを確認します。
      kubectl get pods -n monitoring | grep prometheus 
  5. 次の例を使用して、BesuメトリックのServiceMonitorリソースを作成します。
    apiVersion: monitoring.coreos.com/v1 
    kind: ServiceMonitor 
    metadata: 
      name: obp-besu-rpc-metrics 
      namespace: <besu-namespace> 
      labels: 
        release: monitoring   # Must match Prometheus serviceMonitorSelector 
    spec: 
      selector: 
        matchLabels: 
          app: besu 
          besu-role: rpc 
      namespaceSelector: 
        matchNames: 
          - <besu-namespace> 
      endpoints: 
        - port: metrics 
          path: /metrics 
          interval: 30s 
          scheme: https 
          tlsConfig: 
            caFile: /etc/prom-certs/root-cert.pem 
            certFile: /etc/prom-certs/cert-chain.pem 
            keyFile: /etc/prom-certs/key.pem 
            insecureSkipVerify: true 
    証明書パスは、マウントされた場所(etc/prom-certs)と一致する必要があります。releaseラベルは、PrometheusのserviceMonitorSelector値と一致する必要があります。前述の例では、RPCノード(besu-role: rpc)からメトリックをスクレイプしています。ブート・ノード、バリデータ・ノードまたはアーカイブ・ノードからメトリックをスクレイプするには、個別のServiceMonitorリソースを作成し、besu-roleラベルを適宜編集します(bootnodevalidatorまたはarchive)。
  6. Prometheusでメトリックが収集されていることを確認します。
    1. 次のコマンドを実行して、Prometheusサービスのポートを転送します。
      kubectl port-forward -n <namespace> prometheus-monitoring-kube-prometheus-prometheus-
    2. http://localhost:9090を開き、「ステータス」「ターゲット」の順に選択します。Besuターゲットが UP状態であることを確認します。
    3. 次の例のようなサンプル問合せを実行します。
      besu_blockchain_chain_head_transaction_count 
  7. Grafanaにアクセスして、メトリックが収集されていることを確認します。次のコマンドを実行して、Grafanaサービスのポートを転送します。
    kubectl port-forward svc/monitoring-grafana -n <namespace> 3000:80 
    • URL: http://localhost:3000
    • ユーザー名: admin
    • 次のコマンドを実行して、パスワードを取得します:
      kubectl get secret -n <namespace> monitoring-grafana \ 
      -o jsonpath="{.data.admin-password}" | base64 --decode ; echo