Prometheus サーバー・メトリック・フォワーディングの設定
Prometheus メトリクス・エクスポーター、 sap_host_exporter
および hanadb_exporter
は、 SAP HANA および SAP システム・インスタンスからメトリクスを収集するように構成されている。 Prometheus エクスポーターはそれぞれ、 SAP システムからメトリクスを収集し、そのメトリクスをローカルの HTTP ポートに公開する。 プロセスごとに異なる HTTP ポートを使用し、9600
より大きいポート番号を使用する。
golang-github-prometheus-prometheus
パッケージから入手可能な Prometheus サーバーは、収集されたメトリクスをローカルの HTTP ポートからモニタリング摂取エンドポイントに転送するように構成される。
これらのサービスはすべて、 systemd
サービスとしてインストールされ、永続的に実行される。
Prometheus サーバーは、メトリクスを IBM Cloud® モニタリングに転送するために使用されます。
hanadb_exporter
と sap_host_exporter
の全エクスポーター・プロセスを1つの prometheus.yml
ファイルで設定できます。
エージェント・モードの Prometheus サーバーは、以下の機能を実行する。
- HTTPS エンドポイントからメトリクスを収集します。
- メ ト リ ッ ク を リ モー ト エ ン ド ポ イ ン ト に転送 し ます。
以下の手順を使用して、 Prometheus サーバーのメトリック転送を設定します。
-
Prometheus リモート書き込みの設定 」の説明に従って、 Prometheus 設定ファイルを作成する。
すべてのエクスポーター・プロセスからのすべてのメトリクスは、
targets
を定義することによって収集されます。このコンフィギュレーションのテンプレートには、以下のプレースホルダーが含まれている:
<ibmcloud_monitoring_instance_url>
は、 インスタンスの書き換え先を決定する。 IBM Cloud®<ibmcloud_monitoring_authorization_credentials>
は、 モニタリング・インスタンスの認証トークンです。 IBM Cloud®<sap_monitoring_nr>
は、公開されたメトリクスが収集される システム番号です。 SAP
-
Prometheus、以下のコマンドを実行し、ファイル名を指定してコンフィギュレーション・ファイルを作成する。 /etc/prometheus/<sap_monitoring_nr>.yml
global: scrape_interval: 15s evaluation_interval: 20s remote_write: - url: "<ibmcloud_monitoring_instance_url>" authorization: credentials: "<ibmcloud_monitoring_authorization_credentials>" write_relabel_configs: - target_label: instance replacement: 'SAP-<sap_monitoring_nr>-<sap_monitoring_solution_name>' scrape_configs: - job_name: "hanadb_exporter" static_configs: - targets: ['localhost:5<sap_monitoring_nr>02'] relabel_configs: - target_label: domain replacement: 'SAP' - job_name: "sap_host_exporter" static_configs: - targets: ['localhost:5<sap_monitoring_nr>03','localhost:5<sap_monitoring_nr>04','localhost:5<sap_monitoring_nr>05'] # 05 – n: as many as existing SAP Application server relabel_configs: - target_label: domain replacement: 'SAP'
Prometheus コンフィギュレーション・ファイル名の構文は変更しないでください:
/etc/prometheus/<sap_monitoring_nr>.yml
. -
以下のコマンドを使用して、すべての Prometheus 構成ファイルに Prometheus ユーザーパーミッションを強制する。
sudo chown -R prometheus:prometheus /etc/prometheus
sudo chmod 0740 /etc/prometheus
sudo chmod 0640 /etc/prometheus/*
Prometheus デーモンを手動でテストする。
sudo -H -u prometheus /usr/bin/prometheus \ --config.file=/etc/prometheus/${sap_monitoring_nr}.yml \ --storage.agent.path=/opt/prometheus/${sap_monitoring_nr} \ --enable-feature=agent --web.listen-address=localhost:5${sap_monitoring_nr}01
ルート・ユーザーとして、以下の手順で Prometheus サーバーをエージェント・モードで実行するように systemd サービス・パラメーターを設定する。
-
以下の内容を作成し、
/etc/systemd/system/prometheus@.service
ファイルにコピーする。[Unit] Description=Prometheus After=network.target [Service] User=prometheus Group=prometheus Type=simple Restart=always ExecStart=/usr/bin/prometheus --config.file=/etc/prometheus/%i.yml \ --storage.agent.path=/opt/prometheus/%i --enable-feature=agent \ --web.listen-address=localhost:5%i01 ExecReload=/bin/kill -HUP $MAINPID TimeoutStopSec=20s SendSIGKILL=no [Install] WantedBy=multi-user.target
-
以下のコマンドを使用して、設定を有効化し、 Prometheus エージェントを起動して有効にします。
systemctl daemon-reload
sudo systemctl start prometheus@${sap_monitoring_nr}
sudo systemctl enable prometheus@${sap_monitoring_nr}
サービスのステータスを確認する:
systemctl status prometheus@${sap_monitoring_nr}
-
ファイル内のコンフィギュレーションが更新されるたびに、デーモンを再起動する。 /etc/prometheus/<sap_monitoring_nr>.yml.
chown a+r /etc/prometheus/*
systemctl reload prometheus@${sap_monitoring_nr}
メトリックスがダッシュボードに表示されるまでには時間がかかります。
次のステップ
Prometheus サーバーによって収集されたメトリクスを視覚化するには、 監視 Web UI の起動とダッシュボードでの作業を 参照してください。