2.8. 専用サービスモニターの設定

専用のサービスモニターを使用してリソースメトリックパイプラインのメトリックを収集するように OpenShift Container Platform コアプラットフォームモニタリングを設定できます。

専用サービスモニターを有効にすると、kubelet エンドポイントから 2 つの追加メトリクスが公開され、honorTimestamps フィールドの値が true に設定されます。

専用のサービスモニターを有効にすることで、oc adm top pod コマンドや horizontal Pod Autoscaler などで使用される Prometheus Adapter ベースの CPU 使用率測定の一貫性を向上させることができます。

2.8.1. 専用サービスモニターの有効化

openshift-monitoring namespace の cluster-monitoring-config ConfigMap オブジェクトで dedicatedServiceMonitors キーを設定することで、専用サービスモニターを使用するようにコアプラットフォームのモニタリングを設定できます。

前提条件

  • OpenShift CLI (oc) がインストールされている。
  • cluster-admin クラスターロールを持つユーザーとしてクラスターにアクセスできます。
  • cluster-monitoring-configConfigMap オブジェクトを作成している。

手順

  1. openshift-monitoring namespace で cluster-monitoring-config ConfigMap オブジェクトを編集します。

    $ oc -n openshift-monitoring edit configmap cluster-monitoring-config
  2. 次のサンプルに示すように、enabled: true のキーと値のペアを追加します。

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: cluster-monitoring-config
      namespace: openshift-monitoring
    data:
      config.yaml: |
        k8sPrometheusAdapter:
          dedicatedServiceMonitors:
            enabled: true 1
    1
    kubelet /metrics/resource エンドポイントを公開する専用サービスモニターをデプロイするには、enabled フィールドの値を true に設定します。
  3. ファイルを保存して、変更を自動的に適用します。

    警告

    cluster-monitoring-config 設定マップへの変更を保存すると、openshift-monitoring プロジェクトの Pod およびその他のリソースが再デプロイされる場合があります。そのプロジェクトで実行中のモニタリングプロセスも再起動する場合があります。