简介prometheus可以拆分成多个节点进行指标采集。安装环境:CentOS7安装prometheuswget-chttps://github.com/prometheus/prometheus/releases/download/v2.23.0/prometheus-2.23.0.linux-amd64.tar.gztarzxvfprometheus-2.23.0.linux-amd64.tar.gz-C/opt/cd/opt/ln-sprometheus-2.23.0.linux-amd64prometheuscat>/etc/systemd/system/prometheus.service</opt/prometheus/prometheus.yml<`toanytimeseries从这个配置中抓取。-job_name:'prometheus'#metrics_pathdefaultsto'/metrics'#schemedefaultsto'http'.static_configs:-targets:['localhost:9090']-job_name:'servers'file_sd_configs:-refresh_interval:61sfiles:-/opt/prometheus/servers/*.jsonEOFsystemctlrestartprometheusjson格式每个json文件需要是一个数组对象。如果你不需要自定义标签,你可以直接将它们写入目标或者你可以有多个文件[{"targets":["192.168.1.164:9100"],"labels":{"instance":"192.168.1.164","job":"node_exporter"}},{"targets":["192.168.1.167:9100"],"labels":{"instance":"192.168.1.167","job":"node_exporter"}}]安装node_exporter到/opt/node_exporter路径,保持默认端口https://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-amd64.tar.gztarzxvfnode_exporter-1.0.1.linux-amd64.tar.gz-C/opt/cd/opt/ln-snode_exporter-1.0.1.linux-amd64node_exportercat>/etc/systemd/system/node_exporter.service<数据源->添加数据源->选择prometheus->在url栏填写prometheus的地址->最后保存并测试。grafana.com/grafana/dashboards官网已经做了模板,我们直接导入即可。导入面板:鼠标左侧菜单Dashboards->Import->填写id->Load->选择数据源。我经常使用:1860和8919查看node_exporter监控汇总,安装这些服务都是由systemd管理的,操作起来比较方便。这里没有设置告警,可以根据自己的需要设置相应的告警规则,使用alertmanager告警。