仅仅安装它们是不够的,您需要与 .prometheus
thanos
下面我将描述获得结果所需执行的所有步骤。
第一个简短的理论。集成它们的最常见方法是使用thanos sidecar
容器作为prometheus
pod。你可以在这里阅读更多。
这是如何完成的:
(考虑到安装是干净的,可以轻松删除并从头开始重新安装)。
thanos sidecar
被添加到pod prometheus
。
拉kube-prometheus-stack
图:
$ helm pull prometheus-community/kube-prometheus-stack --untar
您将有一个带有图表的文件夹。您需要修改values.yaml
,准确地说是两部分:
# Enable thanosService
prometheus:
thanosService:
enabled: true # by default it's set to false
# Add spec for thanos sidecar
prometheus:
prometheusSpec:
thanos:
image: "quay.io/thanos/thanos:v0.24.0"
version: "v0.24.0"
请记住,此功能仍处于试验阶段:
## This section is experimental, it may change significantly without deprecation notice in any release.
## This is experimental and may change significantly without backward compatibility in any release.
## ref: https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#thanosspec
完成后,prometheus
使用edited 安装图表values.yaml
:
$ helm install prometheus . -n prometheus --create-namespace # installed in prometheus namespace
并检查 sidecar 是否已部署:
$ kubectl get pods -n prometheus | grep prometheus-0
prometheus-prometheus-kube-prometheus-prometheus-0 3/3 Running 0 67s
它应该运行 3 个容器(默认为 2 个)。kubectl describe
您可以使用命令更详细地检查它。
- 设置
thanos
图表并部署它。
拉thanos
图:
$ helm pull bitnami/thanos --untar
编辑values.yaml
:
query:
dnsDiscovery:
enabled: true
sidecarsService: "prometheus-kube-prometheus-thanos-discovery" # service which was created before
sidecarsNamespace: "prometheus" # namespace where prometheus is deployed
保存并安装此图表已编辑values.yaml
:
$ helm install thanos . -n thanos --create-namespace
检查它是否有效:
$ kubectl logs thanos-query-xxxxxxxxx-yyyyy -n thanos
我们对这一行感兴趣:
level=info ts=2022-02-24T15:32:41.418475238Z caller=endpointset.go:349 component=endpointset msg="adding new sidecar with [storeAPI rulesAPI exemplarsAPI targetsAPI MetricMetadataAPI]" address=10.44.1.213:10901 extLset="{prometheus=\"prometheus/prometheus-kube-prometheus-prometheus\", prometheus_replica=\"prometheus-prometheus-kube-prometheus-prometheus-0\"}"
- 现在转到 UI 并查看可用的指标:
好文章值得阅读: