简体   繁体   English

使用 Prometheus 监控 Pod 内部

[英]Monitoring inside Pods with Prometheus

I want to know if it's possible to get metrics for the services inside the pods using Prometheus.我想知道是否可以使用 Prometheus 获取 pod 内服务的指标。

I don't mean monitoring the pods but the processes inside those pods .我的意思不是监视 pod,而是监视这些 pod中的进程 For example, containers which have apache or nginx running inside them along other main services, so I can retrieve metrics for the web server and the other main service (for example a wordpress image which aso comes with an apache configured).例如,容器中有 apache 或 nginx 与其他主要服务一起在其中运行,因此我可以检索 web 服务器和其他主要服务的指标(例如 wordpress 图像,它配置了 apache)。

The cluster already has running kube-state-metrics, node-exporter and blackbox exporter.集群已经运行了 kube-state-metrics、node-exporter 和 blackbox exporter。

Is it possible?是否可以? If so, how can I manage to do it?如果是这样,我该怎么做?

Thanks in advance提前致谢

Prometheus works by scraping an HTTP endpoint that provides the actual metrics. Prometheus 通过抓取提供实际指标的 HTTP 端点来工作。 That's where you get the term "exporter".这就是您获得术语“出口商”的地方。 So if you want to get metrics from the processes running inside of pods you have three primary steps:因此,如果您想从 Pod 内运行的进程获取指标,您需要三个主要步骤:

  1. You must modify those processes to export the metrics you care about.您必须修改这些流程以导出您关心的指标。 This is inherently something that must be custom for each kind of application.这本质上是必须为每种应用程序定制的东西。 The good news is that there are lots of pre-built ones including things like nginx and apache that you mention.好消息是有很多预建的,包括你提到的 nginx 和 apache。 Most application frameworks also have capability to export prometheus metrics.大多数应用程序框架还具有导出普罗米修斯指标的能力。 ex: Microprofile , Quarkus , and many more.例如: MicroprofileQuarkus等等。
  2. You must then modify your pod definition to expose the HTTP endpoint that those processes are now providing.然后,您必须修改您的 pod 定义以公开这些进程现在提供的 HTTP 端点。 Very straightfoward, but will depend on the configuration you specify for your exporters.非常简单,但取决于您为出口商指定的配置。
  3. You must then modify your Prometheus to scrape those targets.然后,您必须修改您的 Prometheus 以抓取这些目标。 This will depend on your monitoring stack.这将取决于您的监控堆栈。 For Openshift you will find the docs here for enabling user workload monitoring , and here for providing exporter details.对于 Openshift,您可以在此处找到用于启用用户工作负载监控的文档,以及在此处用于提供导出器详细信息的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM