Prometheusターゲットのbasic_authを設定する 質問する

Prometheusターゲットのbasic_authを設定する 質問する

prometheus.yml 構成ファイル内のターゲットの 1 つは、static_configs基本認証で保護されています。その結果、Prometheus ターゲット ページでそのターゲットに対して「接続が拒否されました」というエラーが常に表示されます。

特定のターゲットをスクレイピングするときにセキュリティ認証情報を提供するように Prometheus を設定する方法を調べましたが、解決策が見つかりませんでした。見つけたのは、scrape_configドキュメントの セクションで設定する方法でした。 で保護されていない他のターゲットがあるため、これは機能しませんbasic_auth。この課題について私を助けてください。

.ymlこれが私の挑戦に関する設定の一部です。

scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # Override the global default and scrape targets from this job every 5 seconds.
    scrape_interval: 5s
    scrape_timeout: 5s

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      
      - targets: ['localhost:5000']
        labels: 
          service: 'Auth'
      - targets: ['localhost:5090']
        labels:
          service: 'Approval'
      - targets: ['localhost:6211']
        labels:
          service: 'Credit Assessment'
      - targets: ['localhost:6090']
        labels:
          service: 'Sweep'
      - targets: ['localhost:6500']
        labels:

ベストアンサー1

私の場合、別のジョブを作成する必要がありますが(指定どおり)、basic_authはjob_nameと同じインデントレベルにする必要があります。例はこちら

同様に、basic_auth のケースはドメインのルートに表示されないため、パスが必要です。

API エンドポイントを指定した例を次に示します。

  - job_name: 'myapp_health_checks'
    scrape_interval: 5m
    scrape_timeout: 30s
    static_configs:
        - targets: ['mywebsite.org']
    metrics_path: "/api/health"
    basic_auth:
      username: '[email protected]'
      password: 'cfgqvzjbhnwcomplicatedpasswordwjnqmd'

おすすめ記事