在舵图kube-prometheus-stack部署中添加自定义抓取端点 [英] Add custom scrape endpoints in helm chart kube-prometheus-stack deployment

查看:661
本文介绍了在舵图kube-prometheus-stack部署中添加自定义抓取端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先是使用头盔的新手...

First off a little new to using helm...

因此,我正在竭力做到这一点: https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack

So I'm struggling to get the helm deployment of this: https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack

在kubernetes集群中以我想要的方式工作.我喜欢到目前为止所做的一切,但是如何使它刮取自定义终结点呢?我已经看到了: https://github.com/prometheus -community/helm-charts/tree/main/charts/prometheus

To work the way I would like in my kubernetes cluster. I like what it has done so far but how can I make it scrape a custom endpoint? I have seen this: https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus

在标题为"通过注释抓取Pod指标"的部分下.我在kubernetes中的pod部署(然后是节点端口服务)中添加了以下注释:

Under the section titled: "Scraping Pod Metrics via Annotations". I have added the following annotations to the pod deployment (and then the node port service) in kubernetes:

annotations = {
 "prometheus.io/scrape" = "true"
 "prometheus.io/path"   = "/appMetrics/prometheusMetrics"
 "prometheus.io/port"   = "443"
}

但是,当我看普罗米修斯的targets页时,在那儿看不到它.我也没有在配置文件中看到它.所以这让我觉得这个掌舵图没有部署相同的prometheus图.

However, when I look in the targets page of prometheus I don't see it there. I also don't see it in the configuration file. So that makes me think this helm chart isn't deploying the same prometheus chart.

所以现在的问题是,如何使用舵图kube-prometheus-stack设置自定义刮擦终点.根据我的阅读,这是我应该*使用的一种,对吧?

So now the question is, how can I setup a custom scrape endpoint using the helm chart kube-prometheus-stack. From my reading this is the one I should* be using, right?

推荐答案

在下面的custom_values.yaml中尝试并应用它.

Try this below in your custom_values.yaml and apply it.

prometheus:
  prometheusSpec:
    additionalScrapeConfigs:
      - job_name: your_job_name
        scrape_interval: 15s
        kubernetes_sd_configs:
        - role: pod
          namespaces:
            names:
              - your_namespace
        relabel_configs:
        - source_labels: [__meta_kubernetes_namespace]
          action: replace
          target_label: namespace
        - source_labels: [__meta_kubernetes_pod_name]
          action: replace
          target_label: pod
        - source_labels: [__address__]
          action: replace
          regex: ([^:]+)(?::\d+)?
          replacement: ${1}:your_port
          target_label: __address__
        - source_labels: [__meta_kubernetes_pod_label_app]
          action: keep
          regex: your_pod_name

您需要将your_job_nameyour_namespaceyour_portyour_pod_name替换为部署文件.在完成上述指标并按舵图重新安装Prometheus之后,现在我可以看到目标了,并且指标也暴露了.

You need to replace your_job_name, your_namespace, your_port, your_pod_name to your deployment file. After I did the above metric and re-install Prometheus by helm chart, now I can see the target, and the metrics get exposed.

这篇关于在舵图kube-prometheus-stack部署中添加自定义抓取端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆