第2章 メトリクスと Service Mesh
2.1. メトリクスの使用 リンクのコピーリンクがクリップボードにコピーされました!
モニタリングスタックコンポーネントは、すべての OpenShift Container Platform インストールにデフォルトでデプロイされ、Cluster Monitoring Operator (CMO) により管理されます。これらのコンポーネントには、Prometheus、Alertmanager、Thanos Querier などが含まれます。CMO は、プラットフォーム Prometheus インスタンスから Red Hat にデータのサブセットを送信してクラスターの Remote Health Monitoring を容易にする Telemeter クライアントも導入します。
アプリケーションをメッシュに追加すると、CPU とメモリーの使用状況、ネットワーク接続、その他のリソースの使用状況に関するメトリクスとカスタマイズされたアラートを使用して、OpenShift Container Platform で実行しているアプリケーションのクラスター内の健全性とパフォーマンスを監視できます。
2.1.1. Service Mesh を使用した OpenShift モニタリングの設定 リンクのコピーリンクがクリップボードにコピーされました!
Red Hat OpenShift Service Mesh をユーザーワークロード監視と統合することで、サービスメッシュの可観測性を実現できます。ユーザーワークロード監視は、重要な組み込みツールにアクセスでき、Istio 専用コンソールである Kiali を実行するために必要です。
前提条件
- Red Hat OpenShift Service Mesh がインストールされている。
- ユーザーのワークロードの監視が有効になっている。ユーザー定義プロジェクトのモニタリングの有効化 を参照してください。
手順
servicemonitor.ymlという名前の YAML ファイルを作成して、Istio コントロールプレーンを監視します。ServiceMonitorオブジェクトの例apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: istiod-monitor namespace: istio-system spec: targetLabels: - app selector: matchLabels: istio: pilot endpoints: - port: http-monitoring interval: 30s以下のコマンドを実行して、YAML ファイルを適用します。
$ oc apply -f servicemonitor.ymlpodmonitor.ymlという名前の YAML ファイルを作成し、Istio プロキシーからメトリクスを収集します。PodMonitorオブジェクトの例apiVersion: monitoring.coreos.com/v1 kind: PodMonitor metadata: name: istio-proxies-monitor namespace: istio-system1 spec: selector: matchExpressions: - key: istio-prometheus-ignore operator: DoesNotExist podMetricsEndpoints: - path: /stats/prometheus interval: 30s relabelings: - action: keep sourceLabels: ["__meta_kubernetes_pod_container_name"] regex: "istio-proxy" - action: keep sourceLabels: ["__meta_kubernetes_pod_annotationpresent_prometheus_io_scrape"] - action: replace regex: (\d+);(([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4}) replacement: '[$2]:$1' sourceLabels: ["__meta_kubernetes_pod_annotation_prometheus_io_port","__meta_kubernetes_pod_ip"] targetLabel: "__address__" - action: replace regex: (\d+);((([0-9]+?)(\.|$)){4}) replacement: '$2:$1' sourceLabels: ["__meta_kubernetes_pod_annotation_prometheus_io_port","__meta_kubernetes_pod_ip"] targetLabel: "__address__" - sourceLabels: ["__meta_kubernetes_pod_label_app_kubernetes_io_name","__meta_kubernetes_pod_label_app"] separator: ";" targetLabel: "app" action: replace regex: "(.+);.*|.*;(.+)" replacement: "${1}${2}" - sourceLabels: ["__meta_kubernetes_pod_label_app_kubernetes_io_version","__meta_kubernetes_pod_label_version"] separator: ";" targetLabel: "version" action: replace regex: "(.+);.*|.*;(.+)" replacement: "${1}${2}" - sourceLabels: ["__meta_kubernetes_namespace"] action: replace targetLabel: namespace - action: replace replacement: "the-mesh-identification-string"2 targetLabel: mesh_id以下のコマンドを実行して、YAML ファイルを適用します。
$ oc apply -f podmonitor.ymlOpenShift コンソールで Observe
Metrics に移動し、クエリー istio_requests_totalを実行します。注記Metrics の実装では、クエリーが結果を返すまでに数分かかる場合があります。