prometheus安装篇

一、安装

1、下载二进制安装包

https://github.com/prometheus/prometheus/releases/download/v2.25.0/prometheus-2.25.0.linux-amd64.tar.gz

2、解压

root@xxx:~# cd /data
root@xxx:~# tar -xf prometheus-2.25.0.linux-amd64.tar.gz
root@xxx:~#  mv prometheus-2.25.0.linux-amd64 prometheus

3、使用supervisor管理服务

root@xxx:~# apt-get install supervisor
root@xxx:~#  vim /etc/supervisor/conf.d/prometheus.conf
[program:prometheus]
directory= /data/prometheus/
command =  /data/prometheus/prometheus   --config.file="/data/prometheus/prometheus.yml" --web.listen-address="0.0.0.0:9090"   --web.max-connections=200 --storage.tsdb.path="/data/prometheus/data"   --storage.tsdb.retention.time=14d --web.enable-lifecycle
autostart = true
autorestart = true
startretries = 3
user = root
stdout_logfile = /var/log/supervisor/%(program_name)s.stdout.log
stderr_logfile = /var/log/supervisor/%(program_name)s.stderr.log
stdout_logfile_maxbytes = 300MB
stdout_logfile_backups = 10
stderr_logfile_maxbytes = 300MB
stderr_logfile_backups = 5
stopwaitsecs = 900
startsecs = 10

4、prometheus 启动参数解析

4.1、 --config.file="prometheus.yml"
  • 作用: 指定 Prometheus 配置文件的路径。默认文件名是 prometheus.yml
  • 示例: --config.file="/etc/prometheus/prometheus.yml"
4.2、 --storage.tsdb.path="data/"
  • 作用: 指定存储时间序列数据的路径。Prometheus 将指标数据存储在这个目录中。
  • 示例: --storage.tsdb.path="/var/lib/prometheus/data"
4.3、 --web.listen-address="0.0.0.0:9090"
  • 作用: 设置 Prometheus 监听的网络地址和端口。0.0.0.0 表示监听所有网络接口上的请求,默认端口为 9090
  • 示例: --web.listen-address="localhost:9090"
4.4. --storage.tsdb.retention.time=15d
  • 作用: 设置数据保留的时间,超过这个时间的数据将被删除。默认是 15 天。
  • 示例: --storage.tsdb.retention.time=30d (表示保留 30 天的数据)
4.5. --storage.tsdb.retention.size=2GB
  • 作用: 设置最大存储块的字节数。达到这个限制后,旧数据将被删除以释放空间。
  • 示例: --storage.tsdb.retention.size=5GB
4.6. --web.external-url="<URL>"
  • 作用: 配置 Prometheus 对外可访问的 URL,通常在通过反向代理访问时使用。这个 URL 用于生成 Prometheus 自身的链接。
  • 示例: --web.external-url="https://prometheus.example.com"
4.7. --web.enable-lifecycle
  • 作用: 启用通过 HTTP 请求执行关机和重新加载操作。开启后,可以通过发送 HTTP 请求来关闭或重载 Prometheus。
  • 示例: --web.enable-lifecycle
4.8. --log.level=info
  • 作用: 设置日志的最低级别。常用级别包括 debug, info, warn, error
  • 示例: --log.level=warn (只记录警告及以上级别的日志)
4.9. --query.timeout=2m
  • 作用: 设置查询的最大超时时间。超过这个时间,查询将被中止。
  • 示例: --query.timeout=1m (查询超时时间设置为 1 分钟)
4.10. --query.max-concurrency=20
  • 作用: 设置允许并发执行的最大查询数量,防止查询负载过高影响系统性能。
  • 示例: --query.max-concurrency=50 (允许同时执行 50 个查询)
4.11. --alertmanager.notification-queue-capacity=10000
  • 作用: 配置发送到 Alertmanager 的通知队列的容量,避免通知过载。
  • 示例: --alertmanager.notification-queue-capacity=20000
4.12. --storage.tsdb.wal-compression
  • 作用: 启用预写日志(WAL)的压缩,减少存储空间使用,但可能会增加 CPU 负载。
  • 示例: --storage.tsdb.wal-compression
4.13. --web.console.templates="consoles"
  • 作用: 指定 Prometheus 控制台模板目录路径。
  • 示例: --web.console.templates="/etc/prometheus/consoles"
4.14. --enable-feature=remote-write-receiver
  • 作用: 启用实验性功能。比如,remote-write-receiver 允许 Prometheus 接收远程写入数据。
  • 示例: --enable-feature=promql-at-modifier,remote-write-receiver
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值