一、prometheus安装启动

下载promethuse -server

wget https://github.com/prometheus/prometheus/releases/download/v2.26.0/prometheus-2.26.0.linux-amd64.tar.gz
tar xzvf prometheus-2.26.0.linux-amd64.tar.gz
mv prometheus-2.26.0.linux-amd64 prometheus

启动server

cd /usr/local/prometheus/
nohup ./prometheus &
level=info ts=2021-04-22T08:41:43.883Z caller=web.go:540 component=web msg="Start listening for connections" address=0.0.0.0:9090
level=info ts=2021-04-22T08:41:44.211Z caller=main.go:767 msg="Server is ready to receive web requests."

访问 http://10.0.0.250:9090

二、node节点安装启动

下载node_exporter

wget https://github.com/prometheus/node_exporter/releases/download/v1.1.2/node_exporter-1.1.2.linux-amd64.tar.gz
tar xzvf  node_exporter-1.1.2.linux-amd64.tar.gz
mv node_exporter-1.1.2.linux-amd64 node_exporter

启动exporter

cd node_exporter
nohup ./node_exporter &

查看服务是否启动

curl http://localhost:9100/metrics 滚动输出很多监控内容

三、修改配置

server 端prometheus.yaml添加新监控主机,重启

scrape_configs:
   config.
  - job_name: 'prometheus'
    static_configs:
    - targets: ['localhost:9090']
  - job_name: 'k8s01'
    static_configs:
    - targets: ['10.0.0.101:9100']
kill -9 server_id
nohup ./prometheus &

http://10.0.0.250:9090

四、granfana添加图形

在granfana中通过import导入模板

引用 , https://blog.csdn.net/qq_42869878/article/details/109536370