3.3.2. Prometheus インスタンスの設定 (Prometheus Operator を不使用)
Prometheus Operator を使用せずに Prometheus インスタンスをインストールした場合、設定を更新して Fuse Online インテグレーションを監視するのに、Prometheus 設定ファイルを編集し、Prometheus Pod 設定を更新する必要があります。
前提条件
Prometheus 設定ファイル(prometheus-config.yml)への書き込み権限が必要です。OpenShift web コンソールでは、設定ファイルは Resources
手順
Prometheus 設定ファイル(
prometheus-config.yml)を以下のように編集します。スクレープ間隔を 5 秒に設定します。
global: scrape_interval: 5s evaluation_interval: 5s${OPENSHIFT_PROJECT}で Pod をスクレープするよう設定する Kubernetes サービス検出設定とともにintegration-podという名前のスクレープ設定ジョブを追加します。これは通常syndesisnamespace です。- job_name: integration-pods kubernetes_sd_configs: - role: pod namespaces: names: - ${OPENSHIFT_PROJECT}以下のような
relabel_configsセクションを追加します。-
prometheus.io/scrapeラベルが true に設定されたインテグレーション Pod のみをスクレープします。 -
prometheus.io/pathおよびprometheus.io/portラベルから値を使用して、インテグレーション Pod で JMX エクスポーターを収集するために使用されるmetrics_pathおよびaddressラベルを設定します。 - Pod ラベルおよびアノテーションを Prometheus レベルとして追加する。
kubernetes_namespaceおよびkubernetes_pod_nameラベルを作成します。relabel_configsセクションの例は次のとおりです。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__ - action: labelmap regex: __meta_kubernetes_pod_label_(.+) - action: labelmap regex: __meta_kubernetes_pod_annotation_(syndesis.+) - source_labels: [__meta_kubernetes_namespace] action: replace target_label: kubernetes_namespace - source_labels: [__meta_kubernetes_pod_name] action: replace target_label: kubernetes_pod_name
-
Fuse Online インテグレーションは、JVM、Camel、および CXF から多数のメトリクスを公開します。メトリクスに必要なストレージの量を減らすには、以下の
metric_relabel_configsセクションを追加し、Fuse Online コンソールに表示されないメトリクスを除外します。metric_relabel_configs: - source_labels: [__name__] regex: jmx_(.+) action: drop - source_labels: [__name__] regex: jvm_(.+) action: drop - source_labels: [__name__] regex: process_(.+) action: drop - source_labels: [type, __name__] separator: ':' regex: context:(org_apache_camel_ExchangesTotal|org_apache_camel_ExchangesFailed|io_syndesis_camel_StartTimestamp|io_syndesis_camel_LastExchangeCompletedTimestamp|io_syndesis_camel_LastExchangeFailureTimestamp) action: keep注記最後の設定行は、Fuse Online web コンソールに表示される統計に不可欠な Prometheus メトリクスストアに追加するメトリクスを明示的にリストしています。Prometheus インスタンスは、他のメトリクスが除外された場合にこれらのメトリクスの収集を明示的に許可する必要があります。
以下のように、Prometheus Pod 設定が 30 日分のメトリクスを保存するよう更新します。
args: - '--config.file=/etc/prometheus/prometheus.yml' - '--storage.tsdb.retention=30d'