prometheus版本:2.33
一、prometheus配置agent节点
1、prometheus参数
在
官方文档
的“Feature flags”我们可以看到
当prometheus启动时添加“
–enable-feature=agent
”参数,注意:此prometheus仅支持采集指标,不能查询本地数据。
这时需要在prometheus.yml中指定远程核心的prometheus的URL,例如:
remote_write:
– url: “http://
核心prometheusIP:端口
/api/v1/write”
2、完整的启动命令及添加系统服务
启动命令:
/usr/local/prometheus-2.33/prometheus –config.file=/usr/local/prometheus-2.33/prometheus.yml –web.listen-address=”0.0.0.0:9091″ –web.enable-lifecycle
–enable-feature=agent
系统服务:
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
User=root
ExecStart=/usr/local/prometheus-2.33/prometheus –config.file=/usr/local/prometheus-2.33/prometheus.yml –web.listen-address=”0.0.0.0:9091″ –web.enable-lifecycle
–enable-feature=agent
Restart=on-failure
[Install]
WantedBy=multi-user.target
3、注意
在prometheus开启agent模式时,prometheus.yml中必须配置“remote_write”,不能配置alertmanager和rules,因为agent节点仅有采集指标功能,添加alertmanager和rules启动时会报错!!!!
二、prometheus配置server节点
1、prometheus参数
在
官方文档
的“Feature flags”我们可以看到:
需要在核心server添加“–web.enable-remote-write-receiver”参数,允许远程web写入,此处允许的就是agent节点在yml中添加的远程写入,此处就用到了。
2、完整的启动命令及添加系统服务
启动命令:
/usr/local/prometheus-2.33/prometheus
–config.file=/usr/local/prometheus-2.33/prometheus.yml
–web.enable-lifecycle–storage.tsdb.path=/usr/local/prometheus-2.33/data –storage.tsdb.min-block-duration=2h –storage.tsdb.max-block-duration=2h
–web.enable-remote-write-receiver
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
User=root
ExecStart=/usr/local/prometheus-2.33/prometheus
–config.file=/usr/local/prometheus-2.33/prometheus.yml
–web.enable-lifecycle
–storage.tsdb.path=/usr/local/prometheus-2.33/data
–storage.tsdb.min-block-duration=2h
–storage.tsdb.max-block-duration=2h
–web.enable-remote-write-receiver
Restart=on-failure
[Install]
WantedBy=multi-user.target
3、注意
–web.enable-remote-write-receiver
”参数,网络通、存储空间够大就行,job都不用配置,这个比联邦还简洁。
三、对于thanos等高可用架构