裸机上的Thanos

时间:2019-06-28 21:13:15

标签: kubernetes prometheus

我目前已经安装了Prometheus裸机并作为docker容器运行。我用它来监视我们的基础架构以及Kubernetes集群。

为了进行此HA设置,我试图在2个Prometheus实例之前部署代理或查询器。我的第一个目标是尝试Thanos。但是我找不到有关裸机使用的大量文档或信息。这些文档都是关于Kubernetes上Thanos实现的。

有人在裸机上尝试过Thanos吗?

更新:

我使用docker-compose来旋转小车并查询组件:

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查询器仍然无法访问它们。 Sidecar配置中还有其他缺少的东西吗?

2 个答案:

答案 0 :(得分:0)

与在Kubernetes中运行没有太大区别。 K8是清单文件here,但是您应该能够在容器中或容器外部分别运行每个组件。

例如Store 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

Query Gateway

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

Compactor

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)

Ruler

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"

Thanos是Go二进制文件,因此它可以在Go支持作为target的大多数系统上运行。

答案 1 :(得分:0)

要注意的地方:

  1. Docker组成的名称解析不适用于默认网络。因此,必须为所有Thanos组件创建一个明确的网络

  2. 我们不需要在商店网址中输入http。这就是为什么Thanos查询无法与远程.store API连接的问题

现在,一切正常!

相关问题