Thanos-Query/Query-Frontend 不显示任何指标

发布于 2025-01-09 21:27:37 字数 1339 浏览 3 评论 0原文

基本上,我已经使用提供的 helm 从 kube-prometheus-stack 安装了 Prometheus-Grafana图表存储库 prometheus-community

# helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
# helm install kube-prometheus-stack prometheus-community/kube-prometheus-stack

他们工作正常。

但我现在面临的问题是将 Thanos 与现有的 kube-prometheus-stack 集成。

我从 bitnami Helm Chart 存储库 安装了 Thanos

# helm repo add bitnami https://charts.bitnami.com/bitnami
# helm install thanos bitnami/thanos

我可以加载 Thanos 查询前端 GUI,但是那里没有显示任何指标。

thanos 指标thanos 商店

我现在正在努力让它正常工作。是因为来自完全不同的 Helm Chart 的 Thanos 和来自另一个 Helm Chart 的 Prometheus-operator-grafana 堆栈吗?

我在 AWS 上的 Kubernetes 集群是使用 Kops 创建的。而且,我使用 Gitlab pipeline 和 helm 将应用程序部署到集群。

Basically, I had installed Prometheues-Grafana from the kube-prometheus-stack using the provided helm chart repo prometheus-community

# helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
# helm install kube-prometheus-stack prometheus-community/kube-prometheus-stack

They are working fine.

But the problem I am facing now is integrating Thanos with this existing kube-prometheus-stack.

I installed thanos from the bitnami helm chart repo

# helm repo add bitnami https://charts.bitnami.com/bitnami
# helm install thanos bitnami/thanos

I can load the Thanos Query Frontend GUI, but no metrics showing there.

thanos metrics
thanos store

I am struggling now to get it worked properly. Is it because of Thanos from a completely different helm chart and Prometheus-operator-grafana stack from another helm chart ?.

My Kubernetes cluster on AWS has been created using Kops. And, I use Gitlab pipeline and helm to deploy apps to the cluster.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寻梦旅人 2025-01-16 21:27:37

仅仅安装它们是不够的,您需要将 prometheusthanos 集成。

下面我将描述获得结果所需执行的所有步骤。

第一个短理论。集成它们的最常见方法是使用 thanos sidecar 容器作为 prometheus pod。您可以在此处阅读更多信息。

这是如何完成的:

(考虑到安装是干净的,可以轻松删除并从头开始重新安装)。

  1. thanos sidecar 添加到 prometheus pod。

拉取 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"

请记住,此功能仍处于实验阶段:

## 本部分是实验性的,它可能会发生重大变化,而不会在任何版本中发出弃用通知。
## 这是实验性的,可能会在任何版本中不向后兼容的情况下发生重大变化。
## 参考:https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#thanosspec

完成后,安装带有编辑过的 values.yamlprometheus 图表:

$ 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 命令更详细地检查它。

  1. 设置 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\"}"
  1. 现在转到 UI 并查看可用的指标:

在此处输入图像描述

值得一读的好文章:

It's not enough to simply install them, you need to integrate prometheus with thanos.

Below I'll describe all steps you need to perform to get the result.

First short theory. The most common approach to integrate them is to use thanos sidecar container for prometheus pod. You can read more here.

How this is done:

(considering that installation is clean, it can be easily deleted and reinstalled from the scratch).

  1. Get thanos sidecar added to the prometheus pod.

Pull kube-prometheus-stack chart:

$ helm pull prometheus-community/kube-prometheus-stack --untar

You will have a folder with a chart. You need to modify values.yaml, two parts to be precise:

# 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"

Keep in mind, this feature is still experimental:

## 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

Once it's done, install the prometheus chart with edited values.yaml:

$ helm install prometheus . -n prometheus --create-namespace # installed in prometheus namespace

And check that sidecar is deployed as well:

$ kubectl get pods -n prometheus | grep prometheus-0
prometheus-prometheus-kube-prometheus-prometheus-0       3/3     Running   0          67s

It should be 3 containers running (by default it's 2). You can inspect it in more details with kubectl describe command.

  1. Setup thanos chart and deploy it.

Pull the thanos chart:

$ helm pull bitnami/thanos --untar

Edit values.yaml:

query:
  dnsDiscovery:
    enabled: true
    sidecarsService: "prometheus-kube-prometheus-thanos-discovery" # service which was created before
    sidecarsNamespace: "prometheus" # namespace where prometheus is deployed

Save and install this chart with edited values.yaml:

$ helm install thanos . -n thanos --create-namespace

Check that it works:

$ kubectl logs thanos-query-xxxxxxxxx-yyyyy -n thanos

We are interested in this line:

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\"}"
  1. Now go to the UI and see that metrics are available:

enter image description here

Good article to read:

猫瑾少女 2025-01-16 21:27:37

Yuo 不需要更改 Thanos Sidecar pod 名称。
您可以在安装 prometheus 的命名空间中找到 prometheus-kube-prometheus-thanos-discovery。例如,如果您安装在 monitoring 命名空间中,请运行 kubectl get svc -n reporting
还要确保您在thanos helm值文件的sidecarsNamespce字段下指定了正确的命名空间。

Yuo don't need to change thanos sidecar pod name.
You can find the prometheus-kube-prometheus-thanos-discovery in the namespace you installed prometheus. For example, if you installed in monitoring namespace, run kubectl get svc -n monitoring.
Also ensure that you have specified the correct namespace under the sidecarsNamespce field in the thanos helm values file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文