0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

prometheus basic auth

0
Last updated at Posted at 2026-01-24
global:
    scrape_interval: 15s

  scrape_configs:
    - job_name: 'server'
      # 在这里定义锚点 &auth_config
      basic_auth: &auth_config
        username: 'abc'
        password: 'password'
      static_configs:
        - targets: ['1.1.1.1:9300']

    - job_name: 'apisix'
      # 在这里引用锚点 *auth_config
      basic_auth: *auth_config
      metrics_path: /apisix/prometheus/metrics
      static_configs:
        - targets: ['127.0.0.1:9091']
yml auth.yml
basic_auth_users:
  admin: "$2b$12$hNf2lSsxfm0.i4a.1kVpSOVyBCfIB51VRjgBUyv6kdnyTlgWj81Ay." # 密码必须是 bcrypt 哈希值
prometheus --web.config.file=auth.yml --web.listen-address=":9990" --config.file=prometheus.yml --storage.tsdb.retention.time=365d --storage.tsdb.path=/tmp/prometheus-data

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?