prometheus和node_exporter的Web界面默认没有认证的,任何人都可以访问,我们可以加入浏览器的basic auth认证
node_exporter 端
node_exporter, version 1.3.1
sudo apt-get install apache2-utils
htpasswd -nBC 10 "" | tr -d ':\n'
输入密码:XlP**jAen
复制返回值
$2y$10$Os6PjwgYFiKspBMPw5uRXu2za*
新建配置文件 config.yaml
basic_auth_users:
prometheus: $2y$10$Os6PjwgYFiKspBMPw5uRXu2za*******
启动
node_exporter --web.config="config.yaml"
prometheus 端
prometheus, version 2.32.0-rc.1
- job_name: "cloud2"
scrape_interval: 15s
static_configs:
- targets: ["49.xxx.xxx.70:9100"]
basic_auth:
username: prometheus
password: ****
参考
https://inuits.eu/blog/prometheus-tls/
https://prometheus.io/docs/guides/basic-auth/