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