方案一Thanos https://github.com/improbable-eng/thanos 部署要求: prometheus v2.2.1 版本以上 go 1.10 以上版本 用户对象存储的数据库 安装thanos:
go get -v -d github.com/improbable-eng/thanos/..
cd ${GOPATH}/src/github.com/improbable-eng/thanos
make
Sidecarsthanos通过sidecar进程把多个prometheus实例整合起来。sidecar部署在和prometheus同台机器上或同个pod. sidecar要求aprometheus版本在2.0以上。 sidecar负责备份数据到对象存储,并且查询prometheus实例。 启动
thanos sidecar \
--prometheus.url http://localhost:9090 \ # Prometheus's HTTP address
--tsdb.path /var/prometheus \ # Data directory of Prometheus
--gcs.bucket example-bucket \ # Bucket to upload data to
如果不想备份任何数据,在启动时去掉 --gcs.bucket 选项。 目前已经支持的两种存储:Google Cloud Storage, AWS S3 需要使用其他存储需要重写:https://github.com/improbable-eng/thanos/blob/master/pkg/objstore/objstore.go 查询thanos各个组件之间通过高性能的grpc api进行交互。
thanos sidecar \
--prometheus.url http://localhost:9090 \
--tsdb.path /var/prometheus \
--gcs.bucket example-bucket \
--grpc-address 0.0.0.0:19091 \ # gRPC endpoint for Store API (will be used to perform PromQL queries)
--http-address 0.0.0.0:19191 \ # HTTP endpoint for collecting metrics on Thanos sidecar
--cluster.address 0.0.0.0:19391 \ # Endpoint used to meta data about the current node
--cluster.advertise-address 127.0.0.1:19391 \ # Location at which the node advertise itself at to other members of the cluster
--cluster.peers 127.0.0.1:19391 \ # Static cluster peer where the node will get info about the cluster
Query Layer支持查询PromQL在多个prometheus实例。内部通过可容错的最终一致协议gossip实现。支持扩容和自动发现。
【转载】 https://blog.csdn.net/lr982330245/article/details/81736707
|