标签:targe sshd int gets res 模板 dock ash emc
主机列表:
192.168.161.130 : Prometheus
192.168.161.128 : node-1
192.168.161.129 : node-2
解压 prometheus-2.14.0.linux-amd64.tar.gz包
解压放至 /usr/local下
vim /usr/lib/systemd/system/prometheus.service
[Unit]
Description=Prometheus server daemon
[Service]
ExecStart=/usr/local/prome/prometheus --config.file=/usr/local/prome/prometheus.yml
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
systemctl daemon-reload # 加载后台服务
systemctl start | stop | restart | status prometheus
global: # 全局配置段
scrape_interval: 15s
evaluation_interval: 15s
external_labels:
monitor: 'codelab-monitor'
rule_files: # 告警规则配置
scrape_configs: # 监控配置
- job_name: 'prometheus' #监控任务名称
static_configs: # 静态监控配置
- targets: ['192.168.235.130:9090']
labels:
node: prome_server
使用动态发现添加主机
global: # 全局配置段
scrape_interval: 15s
evaluation_interval: 15s
external_labels:
monitor: 'codelab-monitor'
rule_files: # 告警规则配置
scrape_configs: # 监控配置
- job_name: 'prometheus' #监控任务名称
# static_configs: # 静态监控配置
# - targets: ['192.168.235.130:9090']
# labels:
# node: prome_server
file_sd_configs: # 基于配置文件动态发现添加主机
- files: ['/usr/local/prome/sd_config/*.yml'] # 定义服务发现配置路径
refresh_interval: 5s # 5秒发现刷洗发现一次
mkdir /usr/local/prome/sd_config
- targets: # 直接指定动态发现下的 targets 目标主机
- 192.168.235.130:9090
labels: # 给目标主机添加标签标识
node: prome_server
systemctl reload prometheus
[root@localhost ~]# tar zxf node_exporter-0.18.1.linux-amd64.tar.gz
[root@localhost ~]# mv node_exporter-0.18.1.linux-amd64 /usr/local/
[Unit]
Description=Node_exporter server daemon
[Service]
ExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
prometheus添加远程主机监控
在原来的prometheus.yml中添加任务,监控远程主机
# my global config
global:
evaluation_interval: 15s
scrape_interval: 15s
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['192.168.235.130:9090']
labels:
node: prome_server
# file_sd_configs:
# - files: ['/usr/local/prome/sd_config/*.yml']
# refresh_interval: 5s
- job_name: 'node-1' # 添加主机node-1
static_configs:
- targets: ['192.168.235.128:9100']
labels:
node: node-1
- job_name: 'node-2' # 添加主机node-2
static_configs:
- targets: ['192.168.235.129:9100']
labels:
node: node-2
node_exporter 还可以监控系统的服务状态,在启动是指定参数启用服务监控--collector.systemd --collector.systemd.unit-whitelist=服务名称
[Unit]
Description=Node_exporter server daemon
[Service]
ExecStart=/usr/local/node_exporter/node_exporter --collector.systemd --collector.systemd.unit-whitelist=(sshd|docker|nginx).service
Restart=on-failure
[Install]
WantedBy=multi-user.target
grafana 提供了大量的监控模板,针对各种exporter和数据源制作了不同的监控模板,在grafana中导入即可直接使用
https://grafana.com/grafana/dashboards
选择某个监控模板,找到Get this dashboard:
的值,这里针对node-exporter的模板有一个比较好的模板ID:8919
,可以快速实现主机资源的监控。
同样,容器监控也一样。找到合适的模板即可
标签:targe sshd int gets res 模板 dock ash emc
原文地址:https://www.cnblogs.com/anay/p/11871006.html