Hitachi

Hitachi Microservices Platform - Paxos Commit Transaction Orchestrator ユーザーズガイド


3.7.14 Microsoft AzureのマネージドPrometheusによるメトリクス収集のKubernetesマニフェストの作成

Microsoft Azure環境でマネージドPrometheusを使用してHMP-PCTOのメトリクスを収集する場合、次の手順を実施してください。

Microsoft Azure環境のマネージドPrometheusでは、サービスを起動しただけではHMP-PCTOのメトリクスを収集できないため、次のどちらかの定義を設定してください。詳細については、Microsoft Azureの公式ドキュメントを参照してください。

設定例として、configmapによる設定方法の一つであるama-metrics-prometheus-configの記述例およびデプロイ手順を示します。

Kubernetesマニフェストに設定されたアノテーションprometheus.io/*の値を使用してメトリクスを収集します。HMP-PCTOの各Kubernetesマニフェストの.spec.template.metadata.annotationsに次の内容を指定してください。MediatorおよびTP1-Bridgeについては、Helmチャート内で各アノテーションが設定されています。

キー名

値

備考

prometheus.io/scrape

true

値がtrueの場合にメトリクスの収集対象となります。

prometheus.io/path

/hmppcto/metrics※

メトリクス収集用のエンドポイントです。

prometheus.io/port

httpポート番号(Prometheusメトリクス収集用)に指定した値

メトリクス収集用のポートです。

prometheus.io/scheme

httpまたはhttps

メトリクス収集用のスキームです。

注※

「prometheus.io/path」の値は、コンテキストパスを設定していない場合の指定値です。

コンテキストパスを設定している場合は、次の形式で指定してください。

prometheus.io/path: <コンテキストパス>/hmppcto/metrics

コンテキストパスが/context-pathの場合の指定例を次に示します。

prometheus.io/path: /context-path/hmppcto/metrics

ama-metrics-prometheus-configに設定するパラメタ内容および設定値の詳細については、Microsoft AzureおよびPrometheusの公式ドキュメントを参照してください。

重要

メトリクスのスクレイプ時の通信について

ユーザアプリケーションの暗号化通信を使用する場合、Prometheusのメトリクス収集の設定についても暗号化の設定が必要です。詳細についてはMicrosoft AzureおよびPrometheusの公式ドキュメントを参照してください。

〈この項の構成〉

(1) Kubernetesマニフェストの記述例

Kubernetesマニフェストの記述例を次に示します。この例では、Kubernetesマニフェストのファイル名を「ama-metrics-prometheus-config.yaml」としています。

apiVersion: v1
kind: ConfigMap
metadata:
  name: ama-metrics-prometheus-config
  namespace: kube-system
data:
  prometheus-config: |
    global:
      scrape_interval: 30s
    scrape_configs:
      - job_name: 'hmppcto-metrics-scraper'
        kubernetes_sd_configs:
          - role: pod
        relabel_configs:
          - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
            action: keep
            regex: "true"
          - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
            action: replace
            target_label: __metrics_path__
            regex: (.+)
          - source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
            action: replace
            regex: (.+):(?:\d+);(\d+)
            replacement: ${1}:${2}
            target_label: __address__
          - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scheme]
            regex: (https|http)
            target_label: __scheme__
          - source_labels: [__meta_kubernetes_namespace]
            action: replace
            target_label: namespace
          - source_labels: [__meta_kubernetes_pod_name]
            action: replace
            target_label: pod_name
          - source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_name]
            action: replace
            target_label: label_app_kubernetes_io_name
          - source_labels: [__meta_kubernetes_pod_container_name]
            regex: "dependency-checker"
            action: drop
重要

metadata.namespaceパラメタの設定値を「kube-system」から変更しないでください。

(2) Kubernetesマニフェストのデプロイ

作成したKubernetesマニフェストをデプロイしてください。コマンド例を次に示します。

kubectl apply -f ama-metrics-prometheus-config.yaml