1.node_exporter 用户明码验证拜访
yum install httpd-toolshtpasswd -nB "prometheus"[root@node3 node_exporter]# htpasswd -nB "prometheus"New password: Re-type new password: prometheus:$2y$05$TsMfhNUmHVD8PYmrAvWcNO5lisOfL25.5ybV0Z7t4NF43Aq1IennO
node_exporter web.config.yaml
basic_auth_users: prometheus: $2y$05$TsMfhNUmHVD8PYmrAvWcNxO5OxfL25x.5ybV0Z7t4NF43Aq1IennO
启动node_exporter
./node_exporter --web.config=web.config.yaml
设置node_exporter.service
[Unit]Descriptiong=node_exporterDocumentation=After=network.target[Service]WorkingDirectory=/opt/node_exporter/ExecStart=/opt/node_exporter/node_exporter --web.config=/opt/node_exporter/web.config.yamlExecStop=/bin/kill -KILL $MAINPIDType=simpleKillMode=control-groupRestartSec=3s[Install]WantedBy=multi-user.target
从新加载systemd
systemctl daemon-reload
2.将node_exporter退出到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'] - job_name: 'node' basic_auth: username: prometheus password: 123456 static_configs: - targets: ['localhost:9100']
查看配置文件是否正确
./promtool check config prometheus.yml
退出胜利
alertmanager
定义prometheus 规定
prometheus.yml
rule_files: - "rules/*.yml"
rules/target.yml
groups: - name: targetdown rules: - alert: target is down expr: up == 0 for: 1m
查看rules/target.yml
./promtool check rules rulues/target.yml[root@node3 prometheus]# ./promtool check rules rule/target.yml Checking rule/target.yml SUCCESS: 1 rules found
prometheus 具体配置地址
https://prometheus.io/docs/pr...