Hitachi

JP1 Version 13 JP1/Integrated Management 3 - Manager 導入・設計ガイド


3.14.8 ユーザー独自のPrometheusとの連携

ユーザー独自のPrometheusと連携する手順を次に示します。

  1. 前提条件の確認

    JP1/IM - Manager,Prometheus,Alertmanager,Exporterが,インストールおよびセットアップ済みであることが前提条件となります。

  2. クライアントシークレットの発行

    JP1/IM - Managerのクライアントシークレット発行API(/im/api/v1/secret/client/generateInfo)を実行し,クライアントシークレットを取得します。

    注※

    クライアントシークレットシークレットは一度しか取得できないため,必ずコピーを残しておいてください。

    リクエストとレスポンスのメッセージボディーの例を,次に示します。

    • リクエストのメッセージボディー

    {
      "clientId": ">prometheus"
    }
    • レスポンスのメッセージボディー

    {
        "secret": "kABNY0UFwa4K+W5KhLbkva945Whx+sguH65QinFggaW3CZaB6bA0MkgNgKN2FSSs1kORnQHpWUCHitkeBUzEmYHY09d9BR+tg73vSfbh05xStE7qB1idgfzisqhlqu7R+Q+XNA",
        "lastUpdateTime": "2023-05-18T07:59:23Z"
    }

    クライアントシークレット発行APIについては,マニュアル「JP1/Integrated Management 3 - Manager コマンド・定義ファイル・APIリファレンス」の「5.4.5 IMクライアントシークレット発行」を参照してください。

  3. prometheus.ymlの編集

    Prometheusの展開先の直下(prometheus.exeが存在するパス)にあるprometheus.ymlを編集します。

    記載例を次に示します。太字部分はデフォルトから追加または変更した個所を示します。また,斜体部分にはご使用の環境に合わせた値を指定します。

    (記載例)

    # my global config
    global:
      scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
      evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
      # scrape_timeout is set to the global default (10s).
      external_labels:
        jp1_pc_prome_hostname: "Prometheusのホスト名"
    # Alertmanager configuration
    alerting:
      alertmanagers:
        - static_configs:
            - targets:
               - Prometheusのホスト名:Prometheusのポート番号
     
    # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
    rule_files:
      - "alerting_rules.yml※1"
      # - "first_rules.yml"
      # - "second_rules.yml"
     
    # A scrape configuration containing exactly one endpoint to scrape:
    # Here it's Prometheus itself.
    scrape_configs:
      # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
     
      - job_name: '任意の名称※2'
     
        file_sd_configs:
          - files:
            - 'file_sd_config_任意の名称.yml※3'
        relabel_configs:
          - target_label: jp1_pc_nodelabel
            replacement: Windows exporter
     
        metric_relabel_configs:
          - source_labels: ['__name__']
            regex: 'windows_cs_physical_memory_bytes|windows_cache_copy_read_hits_total|windows_cache_copy_reads_total|windows_cpu_time_total|windows_logical_disk_free_bytes|windows_logical_disk_idle_seconds_total|windows_logical_disk_read_bytes_total|windows_logical_disk_read_latency_seconds_total|windows_logical_disk_read_seconds_total|windows_logical_disk_reads_total|windows_logical_disk_requests_queued|windows_logical_disk_size_bytes|windows_logical_disk_write_bytes_total|windows_logical_disk_write_latency_seconds_total|windows_logical_disk_write_seconds_total|windows_logical_disk_writes_total|windows_memory_available_bytes|windows_memory_cache_bytes|windows_memory_cache_faults_total|windows_memory_page_faults_total|windows_memory_pool_nonpaged_allocs_total|windows_memory_pool_paged_allocs_total|windows_memory_swap_page_operations_total|windows_memory_swap_pages_read_total|windows_memory_swap_pages_written_total|windows_memory_system_cache_resident_bytes|windows_memory_transition_faults_total|windows_net_bytes_received_total|windows_net_bytes_sent_total|windows_net_bytes_total|windows_net_packets_sent_total|windows_net_packets_received_total|windows_system_context_switches_total|windows_system_processor_queue_length|windows_system_system_calls_total'
            action: 'keep'
     
    remote_write:
      - url: http://JP1/IM - Managerのホスト名:インテリジェント統合管理基盤のポート番号/im/api_system/v1/trendData/write
        remote_timeout: 30s
        send_exemplars: false
        queue_config:
          capacity: 10000
          max_shards: 200
          min_shards: 4
          max_samples_per_send: 3000
          batch_send_deadline: 10s
          min_backoff: 100ms
          max_backoff: 10s
        basic_auth:
          username: 'JP/IM - Managerのクライアントシークレット発行APIで指定したクライアントID'
          password: 'JP/IM - Managerのクライアントシークレット発行APIで発行したクライアントシークレット'
    注※1

    手順6で説明するアラート設定ファイルのファイル名を指定します。

    注※2

    Exporterごとにスクレイプ定義を記述します。

    注※3

    手順4で説明するディスカバリ設定ファイルのファイル名を指定します。

  4. ディスカバリ設定ファイルの作成

    ディスカバリ設定ファイル(file_sd_config_任意の名前.yml)を作成し,Prometheusの展開先の直下に配置します。

    記載例を次に示します。斜体部分にはご使用の環境に合わせた値を指定します。

    (記載例)

    - targets:
      - Exporterのホスト名:Exporterのポート番号
      labels:
        jp1_pc_exporter: 任意の名称※1
        jp1_pc_category: platform
        jp1_pc_trendname: 任意の名称※2
    注※1

    「JPC_」から始まらない任意の名称を指定します。

    注※2

    メトリック定義ファイルのファイル名(metrics_任意のPrometheusトレンド名.conf)の「任意のPrometheusトレンド名」の部分と一致する名称を指定する必要があります。

  5. alertmanager.ymlの編集

    Alertmanagerの展開先の直下(alertmanager.exeが存在するパス)のalertmanager.ymlを編集します。

    記載例を次に示します。太字部分はデフォルトから追加した個所を示します。また,斜体部分にはご使用の環境に合わせた値を指定します。

    (記載例)

    route:
      receiver: 'JP1IMDD'
      group_by: ['...']
      continue: false
      group_wait: 5s
      group_interval: 5s
      repeat_interval: 7d
     
    receivers:
    - name: 'JP1IMDD'
     
      webhook_configs:
      - send_resolved: true
        url: 'http:// JP1/IM - Managerのホスト名:インテリジェント統合管理基盤のポート番号/im/api_system/v1/events/transform'
        http_config:
          basic_auth:
            username: 'JP/IM - Managerのクライアントシークレット発行APIで指定したクライアントID'
            password: 'JP/IM - Managerのクライアントシークレット発行APIで発行したクライアントシークレット'
  6. アラート設定ファイルの作成

    アラート定義ファイル(任意の名称)を作成し,Prometheusの展開先の直下に配置します。

    記載例を次に示します。記載例以外のアラート定義ファイルを作成したい場合は,マニュアル「JP1/Integrated Management 3 - Manager コマンド・定義ファイル・APIリファレンス」(2. 定義ファイル)の,各Exporterのメトリック定義ファイルの「モデルファイルの設定内容(初期状態)とアラート定義例」を参照してください。

    (定義例)

    groups:
      - name: windows_exporter
        rules:
        - alert: cpu_used_rate(Windows exporter)
          expr: 0 < 100 - (avg by (instance,job,jp1_pc_nodelabel,jp1_pc_exporter)
          for: 3m
          labels:
            jp1_pc_product_name: "/HITACHI/JP1/JPCCS2"
            jp1_pc_component: "/HITACHI/JP1/JPCCS/CONFINFO"
            jp1_pc_severity: "Error"
            jp1_pc_eventid: "0401"
            jp1_pc_metricname: "windows_cpu_time_total"
          annotations:
            jp1_pc_firing_description: "CPU使用率がしきい値(0%)を上回りました。value={{ $value }}%"
            jp1_pc_resolved_description: "CPU使用率がしきい値(0%)を下回りました。"
  7. メトリック定義ファイルの作成

    メトリック定義ファイルを作成し,次のパスに配置します。

    JP1/IM - Managerのインストール先ディレクトリ\conf\imdd\plugin\jp1pccs\user\

    定義する対象がJP1/IM - Agentで監視可能なExporterとメトリックの場合は,JP1/IM - Agentが提供するファイル(JP1/IM - Managerのインストール先ディレクトリ\conf\imdd\plugin\jp1pccs\*.conf)をそのまま使用できます。

  8. Exporter,Alertmanager,Prometheusの起動

    Exporter,Alertmanager,Prometheusを起動します。

  9. ツリーの生成と反映

    コマンドプロンプトを管理者モードで起動し,次のコマンドを実行します。

    • jddsetacccessuser(すでに実行済みの場合は実行不要)

    • jddcreatetree

    • jddupdatetree

  10. ツリーの確認

    統合オペレーション・ビューアーにログインし,Prometheus,Alertmanager,Exporterのノードが作成されていることを確認します。