安装Prometheus
官网下载
https://prometheus.io/download/#memcached_exporter
下载上传到本地
tar zxf prometheus-2.46 -C /home
cd /home/prometheus-2.46
创建systemd的启动文件
vim /usr/lib/systemd/system/prometheus.service
[Unit]
Description=prometheus
[Service]
Type=simple
ExecStart=/home/pro/prometheus --config.file=/home/pro/prometheus.yml
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start prometheus
systemctl enable prometheus
网页验证
本地ip:9090
添加node_exporter
官网下载
https://prometheus.io/download/#memcached_exporter
上传到本地
tar zxf node_exporter -C /home
添加systemd启动文件
vim /usr/lib/systemd/system/node_exporter.service
[Unit]
Description=prometheus node_exporter
[Service]
Type=simple
ExecStart=/home/node_exporter/node_exporter
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
#RestartSec=42s
#MemoryLimit=300M //内存最大占用300M
#CPUQuota=100% //最多占用一个CPU线程
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start node_exporter
systemctl enable node_exporter
修改Prometheus的配置文件
vim /home/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"
static_configs:
- targets: ["localhost:9100"] //注意端口
systemctl restart prometheus
登录Prometheus验证