下载解压
可以直接下载二进制包,也可以自己下载源码包编译,下载地址:https://prometheus.io/download/
代码语言:javascript复制wget https://github.com/prometheus/prometheus/releases/download/v2.36.0/prometheus-2.36.0.linux-amd64.tar.gz
tar -zvxf prometheus-2.36.0.linux-amd64.tar.gz
cd prometheus-2.36.0.linux-amd64
配置项:
代码语言:javascript复制# 全局配置
global:
scrape_interval: 15s # 设置抓取间隔,默认1分钟,配置是15秒
evaluation_interval: 15s # 估算规则的默认周期,默认1分钟,配置是15秒
# scrape_timeout # 抓取超时时间,默认10秒
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# 规则文件列表,使用 evaluation_interval 间隔去抓取
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# 抓取节点配置,使用 scrape_interval 间隔去抓取
scrape_configs:
# prometheus默认的节点配置
- job_name: "prometheus"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ["localhost:9091"]
运行
代码语言:javascript复制./prometheus --config.file=./prometheus.yml --web.listen-address=0.0.0.0:9091 --storage.tsdb.path=/usr/local/prometheus-2.36.0.linux-amd64/data
启动成功截图:
转为服务开机自启动
代码语言:javascript复制# vim /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/
After=network.target
[Service]
ExecStart=/usr/local/prometheus-2.36.0.linux-amd64/prometheus --config.file=/usr/local/prometheus-2.36.0.linux-amd64/prometheus.yml --storage.tsdb.path=/usr/local/prometheus-2.36.0.linux-amd64/data --web.listen-address=0.0.0.0:9091
WorkingDirectory=/usr/local/prometheus-2.36.0.linux-amd64/
Restart=on-failure
[Install]
WantedBy=multi-user.target
启动服务
代码语言:javascript复制 systemctl start prometheus
systemctl status prometheus
systemctl enable prometheus
查看
访问:localhost:9090 即可看到prometheus自带的ui:
本文为仙士可原创文章,转载无需和我联系,但请注明来自仙士可博客www.php20.cn