prometheus使用agent模式采集指标数据

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等高可用架构

当然了agent节点不支持查询功能,thanos-sidecar等一系列功能都得在核心server上做,所以,这个模式时支持thanos的,亲测可用!!!!!
架构:
四、优势
可以解决当只有prometheus核心节点做采集时高内存的问题。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值