Prometheus -NodeExporter设置密码
Prometheus(2)–Prometheus监控主机信息-Node-Exporter - 点击领取 (dianjilingqu.com)
Prometheus Node Export 基于用户名密码访问_wx5bcd2f496a1cf的技术博客_51CTO博客
安装NodeExporter
下载地址:https://github.com/prometheus/node_exporter/releases/tag
命令:wget https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz
解压:`tar -zxvf node_exporter-1.5.0.linux-amd64.tar.gz -C /usr/local/sofewares/node_exporter
配置密码
`
生成基本认证密码
apt install apache2-utils
htpasswd -nBC 12 '' | tr -d ':\n'
新建配置文件:
basic_auth_users: |
安装到sysntemctl:
- 编辑service文件:
vim /etc/systemd/system/node_exporter.service
[Unit]
Description=node_exporter Monitoring System
Documentation=node_exporter Monitoring System
After=network.target
[Service]
Type=simple
User=root
ExecStart=/usr/local/sofewares/node_exporter/node_exporter --web.listen-address=:9100 --web.config.file=/usr/local/sofewares/node_exporter/node-exporterconfig.yml
Restart=on-failure
[Install]
WantedBy=multi-user.target - 开启自启
systemctl daemon-reload
systemctl start node_exporter.service
systemctl status node_exporter.service
systemctl enable node_exporter.service
开启TLS证书
自签名证书
- 生成证书文件:openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 -keyout node_exporter.key -out node_exporter.crt -subj “/C=CN/ST=Beijing/L=Beijing/O=test.cn/CN=localhost”
加入node-exporterconfig.yml
:tls_server_config:
cert_file: node_exporter.crt
key_file: node_exporter.key - Prometheus配置开启TLS
- job_name: 'node_exporter'
scheme: https
tls_config:
ca_file: node_exporter.crt(自签名证书)
basic_auth:
username: node-exporter 用户名
password: 密码
static_configs:
- targets: ['xxxx:9100']
CA证书
自行使用acme或域名供应生申请ssl
配置node-exporterconfig.yml
:
tls_server_config: |
- Prometheus配置开启TLS
- job_name: 'node_exporter'
scheme: https
basic_auth:
username: node-exporter 用户名
password: 密码
static_configs:
- targets: ['xxxx:9100']
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 Bai's Blog!