参考查看链接 prometheus-basic_auth加密配置
prometheus
prometheus.yml
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "prometheus"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ["localhost:9090"]
basic_auth:
username: 1111
password: 1111
- job_name: node
static_configs:
- targets: ['111:9100']
- targets: ['111:9100']
basic_auth:
username: 1111
password: 1111
添加一个config.yml文件,用参考教程里的生成一个长密码
basic_auth_users:
# 当前设置的用户名为admin, 可以设置多个
adminadmin: $2y$12$9iHkTLGS$2y$12$9iHkTLGS$2y$12$9iHkTLGS$2y$12$9iHkTLGS
启动命令变成 /opt/prometheus/prometheus-2.39.1.linux-amd64/prometheus --config.file=/opt/prometheus/prometheus-2.39.1.linux-amd64/prometheus.yml --web.config.file=/opt/prometheus/prometheus-2.39.1.linux-amd64/config.yml
node-exporter
node-exporter也是一样的步骤,复制config.yml,启动的时候加上--web.config什么什么的就行了 such as
/opt/node-exporter/node_exporter --web.config=/opt/node-exporter/config.yml
记得最后改prometheus里面的 prometheus.yml 两个都要加上basic auth
Comments NOTHING