prometheus 简单例子
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_exporter
Documentation=
After=network.target[Service]
WorkingDirectory=/opt/node_exporter/
ExecStart=/opt/node_exporter/node_exporter --web.config=/opt/node_exporter/web.config.yaml
ExecStop=/bin/kill -KILL $MAINPID
Type=simple
KillMode=control-group
RestartSec=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=` 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 详细配置地址
【prometheus 简单例子】https://prometheus.io/docs/pr...
推荐阅读
- 科学养胃,别被忽悠,其实真的很简单
- opencv|opencv C++模板匹配的简单实现
- 松软可口易消化,无需烤箱超简单,新手麻麻也能轻松成功~
- 简单心理2019春A期+32+张荣
- 《算法》-图[有向图]
- android防止连续点击的简单实现(kotlin)
- 机器学习一些简单笔记
- Android超简单实现沉浸式状态栏
- v-charts简单使用
- 校园非自愿来访者辅导问句学习