IBM Cloud Docs
Prometheus Blackbox エクスポーターを使用した状態メトリックの収集

Prometheus Blackbox エクスポーターを使用した状態メトリックの収集

Prometheus Blackbox エクスポーターは、HTTP、HTTPS、DNS、TCP、および ICMP を使用してエンドポイントのブラックボックス・プロービングを実行できます。 モニタリング・エージェントと一緒に Blackbox エクスポーターを使用することで、状態メトリックを収集できます。 その状態メトリックに基づいて IBM Cloud Monitoring でアラートを生成して、エンドポイントの状態をユーザーに通知できます。

Prometheus の Blackbox エクスポーターを構成するには、以下の手順を実行します。

メトリックを収集するためのモニター・エージェントの構成

1 つ以上のホストをモニターするには、モニタリング・エージェントを構成する必要があります。 このエージェントは、モニタリング UI でモニターできる一連のメトリックを自動的に収集します。

インフラストラクチャによるエージェントタイプの選択 」を参照し、ホストの監視用に構成する監視エージェントを選択します。

Prometheus Blackbox Exporter のインストール

次の手順に従って、Blackbox エクスポーターを Docker コンテナーとして実行します。

  1. Github から blackbox.yml ファイル をダウンロードします。

    このファイルを /config/prometheus/blackbox/ ディレクトリーに保存します。

  2. 以下のように Blackbox エクスポーターを Docker コンテナーとして実行します。

    docker run --rm -d -p 9115:9115 -l io.prometheus.scrape=true -l io.prometheus.port=9115 -l io.prometheus.path=/probe --name blackbox_exporter -v `pwd`:/config/prometheus/blackbox prom/blackbox-exporter:master --config.file=/config/prometheus/blackbox/blackbox.yml
    
  3. このエクスポーターが稼働していることを確認します。 以下のコマンドを実行します。

    docker container ls
    

    以下のような出力になります。

    CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS              PORTS                    NAMES
    2480a0034bb4        prom/blackbox-exporter:master   "/bin/blackbox_expor…"   36 minutes ago      Up 36 minutes       0.0.0.0:9115->9115/tcp   blackbox_exporter
    

    Blackbox コンテナーを停止するには、コマンド docker container stop 2480a0034bb4 を実行します。

ネットワーク設定を構成する

リモート・サーバーからメトリックを収集する場合は、以下の手順を実行します。

  1. blackbox_exporter へのアクセスがファイアウォールで許可されるようにします。

  2. [オプション] VPC ルールの更新

    プライベート・エンドポイントを使用する場合は、9115 を指定してポート source type = Security Group のインバウンド・ルールをセキュリティー・グループに追加し、そのセキュリティー・グループをサーバー用に選択します。

サーバーで実行されているモニター・エージェントを更新します。

以下のコマンドを実行して、構成マップを編集し、Kubernetes モニタリング・エージェントを使用してモニターする Blackbox ターゲットに関する情報を追加します。

kubectl edit configmap sysdig-agent -n ibm-observe
log:
  file_priority: error
configmap: true
### Agent tags
# tags: linux:ubuntu,dept:dev,local:nyc

#### Monitoring Software related config ####

# Monitoring collector address
# collector: 192.168.1.1

# Collector TCP port
# collector_port: 6666

# Whether collector accepts ssl
# ssl: true

# collector certificate validation
# ssl_verify_certificate: true

#######################################
# new_k8s: true
# k8s_cluster_name: production
security:
  k8s_audit_server_url: 0.0.0.0
  k8s_audit_server_port: 7765
k8s_cluster_name: <CLUSTER_NAME>/<CLUSTER_ID>
tags: ibm.containers-kubernetes.cluster.id:<CLUSTER_ID>
collector: <INGESTION_ENDPOINT>
collector_port: 6443
ssl: true
ssl_verify_certificate: true
sysdig_capture_enabled: false
promscrape_fastproto: true
use_promscrape: true
prometheus:
  enabled: true
  prom_service_discovery: true
  log_errors: true
  max_metrics: 200000
  max_metrics_per_process: 200000
  max_tags_per_metric: 100
  ingest_raw: true
  ingest_calculated: false
prometheus.yaml:
----
global:
  scrape_interval: 10s
scrape_configs:
- job_name: blackbox
  metrics_path: /probe
  params:
    module: [http_2xx]
  static_configs:
  - targets:
    - https://prometheus.io/
    - https://www.google.com/search?q=promcat
    - https://www.ibm.com/software/passportadvantage
  relabel_configs:
  - source_labels: [__address__]
    target_label: __param_target
  - source_labels: [__param_target]
    target_label: instance
  - source_labels: [__param_target]
    target_label: blackbox_instance
  - target_label: __address__
    replacement: blackbox-exporter.ibm-observe:9115

説明

  • <IP_ADDRESS_OF_REMOTE_SERVER>は、モニター対象となるサーバーの IP アドレスです。
  • <INGESTION_ENDPOINT>は、IBM Cloud Monitoring インスタンス取り込みエンドポイント (例えば、ingest.us-south.monitoring.cloud.ibm.com) です。 コレクター・エンドポイントを参照してください。

ファイルを保存すると、変更内容が適用されます。

サーバーの Blackbox 状況を分析するためのデフォルトのダッシュボードとアラートの構成

以下のステップを実行します。

  1. モニタリング UI を起動します

  2. ダッシュボードを作成します。

  3. 以下の照会ごとにパネルを追加します。

Blackboxエクスポーターのサンプルクエリ
メトリック 照会 オプション
インスタンス別の状況コード probe_http_status_code{instance=$instance} number (auto)
SSL 証明書の有効期限の日数 probe_ssl_earliest_cert_expiry{instance=$instance}-time() time (auto)
DNS 参照 probe_dns_lookup_time_seconds{instance=$instance} time (auto)
プローブの期間 probe_duration_seconds{instance=$instance} time (auto)

例えば、以下のようなダッシュボードを作成できます。

サンプルBlackboxダッシュボード
Blackboxダッシュボード
サンプルBlackboxダッシュボード