二进制下载地址:https://prometheus.io/download/
下载以 linux-amd64.tar.gz 结尾的文件。
1.下载二进制压缩包
wget -P /home https://github.com/prometheus/prometheus/releases/download/v2.41.0/prometheus-2.41.0.linux-amd64.tar.gz
2.解压
cd /home && mkdir prometheus && tar -zxvf prometheus-2.41.0.linux-amd64.tar.gz --strip-components 1 -C /home/prometheus mv /home/prometheus /usr/local/bin
3.编辑启动的配置文件
# 我的全局配置 global: scrape_interval: 15s # 将刮擦间隔设置为每15秒钟,默认为每1分钟. evaluation_interval: 15s # 每 15 秒评估一次规则。 默认为每 1 分钟一次. # scrape_timeout 设置为全局默认值(10s). # 警报管理器配置 alerting: alertmanagers: - static_configs: - targets: # - alertmanager:9093 # 加载一次规则并根据全局“evaluation_interval”定期评估它们. rule_files: # - "first_rules.yml" # - "second_rules.yml" # 一个仅包含一个要抓取的端点的抓取配置: # 这是 Prometheus 本身。. scrape_configs: # 作业名称将作为标签“job=”添加到此配置中刮取的任何时间序列. - job_name: "prometheus" # metrics_path 默认为“/metrics” # 方案默认为“http”. static_configs: - targets: ["localhost:9090"]
修改为如下内容:
global: scrape_interval: 15s evaluation_interval: 15s alerting: alertmanagers: - static_configs: - targets: rule_files: scrape_configs: - job_name: "prometheus" static_configs: - targets: ["192.168.182.128:9090"]
4.开放防火墙端口
firewall-cmd --zone=public --add-port=9090/tcp --permanent //添加端口 firewall-cmd --reload //重载 firewall-cmd --zone=public --query-port=9090/tcp //查询端口开放是否成功
5.启动测试
./prometheus --config.file=prometheus.yml
6.注册为服务,用于自启动
1.编写service文件
cat > /usr/lib/systemd/system/prometheus.service << EOF [Unit] Description=Prometheus Server After=network.target Documentation=https://prometheus.io/docs/introduction/overview/ [Service] Type=simple ExecStart=/usr/local/bin/prometheus/prometheus --config.file=/usr/local/bin/prometheus/prometheus.yml --web.read-timeout=5m --web.max-connections=512 --storage.tsdb.retention=15d --storage.tsdb.path=/home/data/prometheus --query.timeout=2m Restart=on-failure [Install] WantedBy=multi-user.target EOF
2.设置自启动
systemctl daemon-reload systemctl enable prometheus systemctl start prometheus
标签:Centos,二进制,interval,9090,prometheus,scrape,--,Prometheus,configs From: https://www.cnblogs.com/fanqisoft/p/17047641.html