thanos 配置receive模式

前言

prometheus+thanos做集群用到的几种模块

thanos query :查询模块

thanos sidecar :读取prometheus采集指标数据并存储到对象存储的模块

thanos receive :接收prometheus数据并存储到对象存储的模块

thanos store :连接对象存储并提供查询的模块

一、sidecar和receive的使用的场景是什么?

1.1、sidecar

边车模式,需要与prometheus部署到同一台服务器上,也是大多数thanos做集群用到的模块。

同时必须在prometheus启动时配置

--storage.tsdb.min-block-duration=2h

--storage.tsdb.max-block-duration=2h

否则sidecar启动报错!

1.2、receive

提供远程写入的API,允许远程prometheus将数据写入thanos receive中,只要远程prometheus与thanos receive 的API接口网络通即可,远程prometheus控制好本地存储的空间就可以。

二、prometheus+thanos{receive,query,store}简单部署

2.1、prometheus安装配置

安装就不说了,主要是prometheus.yml和启动文件配置

配置文件prometheus.yml

vim prometheus.yml

#添加thanos receive远程API地址,其他配置按需要修改

remote_write:
  - url: "http://thanos-receiveIP:19291/api/v1/receive"

启动文件配置

vim start.sh

#!/bin/bash

nohup /usr/local/prometheus/bin/prometheus --config.file="/usr/local/prometheus/config/prometheus.yml" --web.enable-lifecycle --storage.tsdb.retention.size=10GB > /usr/local/prometheus/logs/prometheus.log 2>&1 &

#注意:参数“--storage.tsdb.retention.size=”是为了控制存本地的数据大小到达多少时删除旧数据。

2.2、thanos-receive配置

创建连接对象存储(minio)连接文件

vim receive.yml

type: s3
config:
  bucket: prometheus
  endpoint: minioIP:9000
  access_key: minioadmin
  secret_key: minioadmin
  insecure: true

启动文件配置

vim start-receive.sh

#!/bin/bash

nohup /usr/local/thanos/bin/thanos receive \
--grpc-address="0.0.0.0:10901" \
--http-address="0.0.0.0:10902" \
--receive.replication-factor=1 \
--label "receive_replica=\"1\"" \
--objstore.config-file="/usr/local/thanos/config/receive.yml" \
--remote-write.address="0.0.0.0:19291" \
--tsdb.path="/usr/local/thanos/data/receive" > /usr/local/thanos/logs/receive.log 2>&1 &

参数说明:

--grpc-address : 给thanos query查询用的

--http-address : 对外提供http服务器访问用的

--receive.replication-factor : 指定有几个receive在运行,例如等于3就需要receive同时运行才可以,否则报错

--label "receive_replica : 和sidecar必须指定prometheus的replica功能相同,只不过在receive模式只需在thanos receive启动指定,无需在prometheus配置文件中配置

--remote-write.address : 给远程prometheus写入的提供的API端口

2.3、thanos-query配置

启动文件配置

vim start-query.sh

#!/bin/bash
nohup /usr/local/thanos/bin/thanos query \
--http-address "queryIP:11902" \
--grpc-address="0.0.0.0:11901" \
--store="receiveIP:10901" \
--store="storeIP:39090" > /usr/local/thanos/logs/query.log 2>&1 &

2.4、thanos-store配置

创建连接对象存储(minio)连接文件

vim receive.yml

type: s3
config:
  bucket: prometheus
  endpoint: minioIP:9000
  access_key: minioadmin
  secret_key: minioadmin
  insecure: true

启动文件配置

vim start-store.sh

#!/bin/bash
nohup /usr/local/thanos/thanos store \
--data-dir /usr/local/thanos/data \
--objstore.config-file /usr/local/thanos/prometheus.yml \
--http-address 0.0.0.0:39191 \
--grpc-address 0.0.0.0:39090 \
--min-time=-2w --max-time=-1w > /usr/local/thanos/logs/store.log 2>&1 &

2.5、minio对象存储配置

启动文件配置

vim  start.sh

#!/bin/bash

export MINIO_ACCESS_KEY=minioadmin
export MINIO_SECRET_KEY=minioadmin

nohup /usr/local/minio/bin/minio server --address :9000 /usr/local/minio/data > /usr/local/minio/logs/minio.log 2>&1 &

2.6、启动并访问thanos query验证

顺序启动minio receive store query prometheus

访问query页面

查询node指标

 三、prometheus agent模式+thanos receive模式

prometheus agent模式配置跳转prometheus 配置agent模式,经测试agent 模式和receive模式关联完全没问题,至与压力测试,有测试的小伙伴反馈一下。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值