kubernetes - 裸机上的灭霸
问题描述
我目前已经安装了 Prometheus 裸机并作为 docker 容器运行。我用它来监控我们的基础设施以及 Kubernetes 集群。
为了设置 HA,我尝试在 2 个 Prometheus 实例前部署代理或查询器。我的第一个目标是尝试灭霸。但我没有找到太多关于裸机使用的文档或信息。这些文档都是关于 Kubernetes 上的 Thanos 实现的。
有人在裸机上尝试过灭霸吗?
更新:
我使用 docker-compose 来启动 sidecar 和查询组件:
thanos-sidecar:
image: improbable/thanos:v0.5.0
restart: always
volumes:
- tsdb-vol:/prometheus
command: ['sidecar', '--tsdb.path="/prometheus"', '--prometheus.url=http://metrics_prometheus_1:9090' ]
ports:
- '10902:10902'
- '10901:10901'
depends_on:
- Prometheus
network:
- thanos
thanos-querier:
image: improbable/thanos:v0.5.0
logging:
# limit logs retained on host to 25MB
driver: "json-file"
options:
max-size: "500k"
max-file: "50"
restart: always
command: ['query' , '--http-address=0.0.0.0:19192' , '--query.replica-label=replica' , '--store=metrics_thanos-sidecar_1:10901', '--store=172.XX.XX.XXX:10901']
ports:
- '19192:19192'
depends_on:
- thanos-sidecar
network:
- thanos
我已经在 10901 处公开了 store API 的 gRPC 端口,但是 thanos-querier 仍然无法访问它们。Sidecar 配置中是否还缺少其他内容?
解决方案
它与在 Kubernetes 中运行应该没有太大区别。这里是 K8s 清单文件,但是您应该能够单独运行每个组件,无论是在容器中还是在容器外。
例如,商店 API:
thanos sidecar \
--tsdb.path /var/prometheus \
--objstore.config-file bucket_config.yaml \ # Bucket config file to send data to
--prometheus.url http://localhost:9090 \ # Location of the Prometheus HTTP server
--http-address 0.0.0.0:19191 \ # HTTP endpoint for collecting metrics on the Sidecar
--grpc-address 0.0.0.0:19090 # GRPC endpoint for StoreAPI
或查询网关
thanos query \
--http-address 0.0.0.0:19192 \ # HTTP Endpoint for Query UI
--store 1.2.3.4:19090 \ # Static gRPC Store API Address for the query node to query
--store 1.2.3.5:19090 \ # Also repeatable
--store dnssrv+_grpc._tcp.thanos-store.monitoring.svc # Supports DNS A & SRV records
或压实机
thanos compact \
--data-dir /var/thanos/compact \ # Temporary workspace for data processing
--objstore.config-file bucket_config.yaml \ # Bucket where to apply the compacting
--http-address 0.0.0.0:19191 # HTTP endpoint for collecting metrics on the Compactor)
或标尺
thanos rule \
--data-dir "/path/to/data" \
--eval-interval "30s" \
--rule-file "/path/to/rules/*.rules.yaml" \
--alert.query-url "http://0.0.0.0:9090" \ # This tells what query URL to link to in UI.
--alertmanagers.url "alert.thanos.io" \
--query "query.example.org" \
--query "query2.example.org" \
--objstore.config-file "bucket.yml" \
--label 'monitor_cluster="cluster1"'
--label 'replica="A"
推荐阅读
- python-3.x - 如何在不自动提交的情况下长时间(4-60 分钟)处理 Kafka 消息,并在不遭受重新平衡的情况下提交
- android - 如何将谷歌地图中的相机移动到标记android
- javascript - 计算最优值
- mysql - 在过程中执行 Mysql 查询变量
- python - python中带有两个布尔值的运算符
- typescript - Firebase Cloud Functions - 制作 Telegram Bot 时出现“TypeError:无法读取未定义的属性‘切片’”
- c++ - 如何使用 llvm::IRBuilder 创建 Add/Sub/Mul/Div?
- mysql - 在MySql的描述字段中搜索传递关键字的出现次数
- java - 使用 java 和 spring MVC 构建服务器
- javascript - CORS 策略已阻止访问 XMLHttpRequest (sound.mp3)