ヘルスメトリクス
クラスター全体のヘルスメトリクスとモニタリングについて説明します。
概要
第1章 ヘルスメトリクス
メトリクスを使用してコンポーネントの正常性を監視できます。
以下のドキュメントを参照してください。
1.1. メトリクスサービスの使用
メトリクスを使用して、Red Hat Advanced Cluster Management for Kubernetes 全体のコンポーネントの正常性を監視できます。多くのカスタムメトリックは、メトリッククロニクルの概要 に記載されています。
1.1.1. ハブクラスターメトリクスサービスへのアクセス
収集されたメトリクスを表示するには、ハブクラスター上でメトリクスサービスを公開する必要があります。メトリクスがすでに Grafana ダッシュボードに公開されている場合、この手順はオプションです。
OpenShift Container Platform コンソールから、メトリクスサービスを見つけます。Observe > Metrics をクリックします。
Grafana ダッシュボード、Grafana Explorer、または OpenShift Container Platform コンソールにメトリクスが表示されない場合は、Prometheus がメトリクスを取得するように設定されていない可能性があります。Prometheus を使用したスクラッチ に進み、メトリクスを公開してください。
1.1.2. Prometheus を使用したスクレイピング
Prometheus を使用すると、製品コンソールから公開されていないメトリクスを公開できます。ハブとマネージドクラスターのメトリクスの手順を参照してください。
1.1.2.1. ハブクラスターのスクレイピング
ハブクラスターのメトリクスを公開する手順は次のとおりです。これらのファイルは、openshift-monitoring
namespace 内にあります。
サービスを収集し、メトリクスを公開するための
ServiceMonitor
を作成します。以下は、YAML の例です。apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: hub-subscription-metrics namespace: openshift-monitoring spec: endpoints: - port: metrics namespaceSelector: matchNames: - open-cluster-management selector: matchLabels: app: hub-subscription-metrics
Copy to clipboardCopiedapiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: hub-subscription-metrics namespace: openshift-monitoring spec: endpoints: - port: metrics namespaceSelector: matchNames: - open-cluster-management selector: matchLabels: app: hub-subscription-metrics
次のコマンドを実行して、ファイルを適用します。
oc apply -f
Copy to clipboardCopiedoc apply -f
モニタリング権限を設定する
Role
を作成します。以下は、その YAML ファイルです。apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: prometheus-k8s-monitoring namespace: open-cluster-management rules: - apiGroups: - "" resources: - services - endpoints - pods verbs: - get - list - watch - apiGroups: - extensions resources: - ingresses verbs: - get - list - watch - apiGroups: - networking.k8s.io resources: - ingresses verbs: - get - list - watch
Copy to clipboardCopiedapiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: prometheus-k8s-monitoring namespace: open-cluster-management rules: - apiGroups: - "" resources: - services - endpoints - pods verbs: - get - list - watch - apiGroups: - extensions resources: - ingresses verbs: - get - list - watch - apiGroups: - networking.k8s.io resources: - ingresses verbs: - get - list - watch
次のコマンドを実行して、ファイルを適用します。
oc apply -f
Copy to clipboardCopiedoc apply -f
次の例のように、Prometheus モニタリング
ServiceAccount
にロールをバインドするためのRoleBinding
を作成します。apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: prometheus-k8s-monitoring-binding namespace: open-cluster-management roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: prometheus-k8s-monitoring subjects: - kind: ServiceAccount name: prometheus-k8s namespace: monitoring
Copy to clipboardCopiedapiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: prometheus-k8s-monitoring-binding namespace: open-cluster-management roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: prometheus-k8s-monitoring subjects: - kind: ServiceAccount name: prometheus-k8s namespace: monitoring
次のコマンドを実行して、ファイルを適用します。
oc apply -f
Copy to clipboardCopiedoc apply -f
検証するには、ダッシュボードで次のクエリーを実行し、Subscription Operator Metrics Service により報告されるメトリクスを見つけます。
{service="hub-subscription-metrics"}
Copy to clipboardCopied{service="hub-subscription-metrics"}
1.1.2.2. マネージドクラスターのスクレイピング
マネージドクラスターのメトリクスを公開するには、次の手順を実行します。これらのファイルは、openshift-monitoring
namespace 内にあります。
メトリクスを公開するサービスを収集する
ServiceMonitor
を作成します。以下は、YAML ファイルの例です。apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: mc-subscription-metrics namespace: openshift-monitoring spec: endpoints: - port: metrics namespaceSelector: matchNames: - open-cluster-management-agent-addon selector: matchLabels: app: mc-subscription-metrics
Copy to clipboardCopiedapiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: mc-subscription-metrics namespace: openshift-monitoring spec: endpoints: - port: metrics namespaceSelector: matchNames: - open-cluster-management-agent-addon selector: matchLabels: app: mc-subscription-metrics
次のコマンドを実行してファイルを適用します。
oc apply -f
Copy to clipboardCopiedoc apply -f
モニタリング権限を設定する
Role
を作成します。以下は、YAML ファイルの例です。apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: prometheus-k8s-monitoring namespace: open-cluster-management-agent-addon rules: - apiGroups: - "" resources: - services - endpoints - pods verbs: - get - list - watch - apiGroups: - extensions resources: - ingresses verbs: - get - list - watch - apiGroups: - networking.k8s.io resources: - ingresses verbs: - get - list - watch
Copy to clipboardCopiedapiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: prometheus-k8s-monitoring namespace: open-cluster-management-agent-addon rules: - apiGroups: - "" resources: - services - endpoints - pods verbs: - get - list - watch - apiGroups: - extensions resources: - ingresses verbs: - get - list - watch - apiGroups: - networking.k8s.io resources: - ingresses verbs: - get - list - watch
次のコマンドを実行して、ファイルを適用します。
oc apply -f
Copy to clipboardCopiedoc apply -f
Prometheus モニタリング
ServiceAccount
にRole
をバインドするRoleBinding
を作成します。apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: prometheus-k8s-monitoring-binding namespace: open-cluster-management-agent-addon roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: prometheus-k8s-monitoring subjects: - kind: ServiceAccount name: prometheus-k8s namespace: monitoring
Copy to clipboardCopiedapiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: prometheus-k8s-monitoring-binding namespace: open-cluster-management-agent-addon roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: prometheus-k8s-monitoring subjects: - kind: ServiceAccount name: prometheus-k8s namespace: monitoring
次のコマンドを実行して、ファイルを適用します。
oc apply -f
Copy to clipboardCopiedoc apply -f
Prometheus
ダッシュボードで次のクエリーを実行し、Subscription Operator Metrics Service により報告されるメトリクスを見つけて検証します。{service="mc-subscription-metrics"}
Copy to clipboardCopied{service="mc-subscription-metrics"}
1.1.3. スタンドアロンクラスターのスクレイピング
メトリクスを公開するサービスを収集するための
ServiceMonitor
を作成します。apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: standalone-subscription-metrics namespace: openshift-monitoring spec: endpoints: - port: metrics namespaceSelector: matchNames: - open-cluster-management selector: matchLabels: app: standalone-subscription-metrics
Copy to clipboardCopiedapiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: standalone-subscription-metrics namespace: openshift-monitoring spec: endpoints: - port: metrics namespaceSelector: matchNames: - open-cluster-management selector: matchLabels: app: standalone-subscription-metrics
モニタリング権限を設定するための
Role
を作成します。oc apply -f
Copy to clipboardCopiedoc apply -f
apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: prometheus-k8s-monitoring namespace: open-cluster-management rules: - apiGroups: - "" resources: - services - endpoints - pods verbs: - get - list - watch - apiGroups: - extensions resources: - ingresses verbs: - get - list - watch - apiGroups: - networking.k8s.io resources: - ingresses verbs: - get - list - watch
Copy to clipboardCopiedapiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: prometheus-k8s-monitoring namespace: open-cluster-management rules: - apiGroups: - "" resources: - services - endpoints - pods verbs: - get - list - watch - apiGroups: - extensions resources: - ingresses verbs: - get - list - watch - apiGroups: - networking.k8s.io resources: - ingresses verbs: - get - list - watch
Prometheus モニタリング
ServiceAccount
にRole
をバインドするためのRoleBinding
を作成します。以下は、YAML ファイルの例です。apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: prometheus-k8s-monitoring-binding namespace: open-cluster-management roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: prometheus-k8s-monitoring subjects: - kind: ServiceAccount name: prometheus-k8s namespace: monitoring
Copy to clipboardCopiedapiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: prometheus-k8s-monitoring-binding namespace: open-cluster-management roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: prometheus-k8s-monitoring subjects: - kind: ServiceAccount name: prometheus-k8s namespace: monitoring
次のコマンドを実行して、ファイルを適用します。
oc apply -f
Copy to clipboardCopiedoc apply -f
Prometheus
ダッシュボードで次のクエリーを実行し、Subscription Operator Metrics Service により報告されるメトリクスを見つけて検証します。{service="standalone-subscription-metrics"}
Copy to clipboardCopied{service="standalone-subscription-metrics"}