官网下载最新安装包
tar -xvf prometheus-2.38.0.linux-amd64.tar.gz
移动到安装目录
mv prometheus-2.28.1.linux-amd64 /usr/local/prometheus
进入目录
cd /usr/local/prometheus
修改prometheus的配置
vi /usr/local/prometheus/prometheus.yml
添加如下内容
- job_name: 'collector_high_level'
metrics_path: '/highLevel'
file_sd_configs:
- refresh_interval: 15s
files:
- ./conf.d/*.json
- job_name: 'collector_low_level'
metrics_path: '/lowLevel'
file_sd_configs:
- refresh_interval: 30s
files:
- ./conf.d/*.json
创建conf.d目录
cd /usr/local/
mkdir conf.d
配置系统服务
进入systemd目录
cd /usr/lib/systemd/system
vim prometheus.service
添加如下内容
[Unit]
Description=https://prometheus.io
[Service]
Restart=on-failure
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml
[Install]
WantedBy=multi-user.target
生效系统systemd文件,开机自启动
systemctl daemon-reload
systemctl enable prometheus
启动和停止服务命令
# 启动
systemctl start prometheus.service
# 停止
systemctl stop prometheus.service
查看进程
systemctl status prometheus
关闭防火墙
systemctl stop firewalld
- 页面访问
http://127.0.0.1:9090/targets?search=