度量在普罗米修斯中不可见

问题描述

我正在使用弹性搜索导出器将弹性搜索指标提取到Prometheus。 我安装了头盔图表,可以通过端口转发在http://127.0.0.1:9108/metrics上查看指标。 但是我看不到普罗米修斯有任何度量标准。 有人可以告诉我从哪里开始排查问题吗?

解决方法

TL; DR

您尚未设置PodMonitorServiceMonitor
您需要根据prometheus-operator/Documentation#servicemonitor

创建一个

您可以使用我的头盔图表kehao95/helm-prometheus-exporter安装各种普罗米修斯出口商,包括elasticsearch-exporter
它将不仅为您创建导出器Deployment,还将为您创建Service / ServiceMonitor / PrometheusRule

  1. 安装图表
helm repo add kehao95 https://kehao95.github.io/helm-prometheus-exporter
  1. 获取elasticsearch-exporter示例
wget https://raw.githubusercontent.com/kehao95/helm-prometheus-exporter/master/examples/elasticsearch-exporter.values.yaml
# or create a new one
helm show values kehao95/prometheus-exporter > elasticsearch-exporter.values.yaml
  1. 更新值文件中的elasticsearch连接信息。
  2. 安装头盔
helm install -n monitoring elasticsearch-exporter kehao95/prometheus-exporter -f elasticsearch-exporter.values.yaml

说明

因为您可以在导出器上通过port-forward查看指标。这意味着您有出口商在工作。 但是数据不会自动出现在普罗米修斯身上。您需要配置Prometheus才能在导出器的指标端点上抓取。

在prometheus-operator中工作的出口商堆栈需要:

    出口商的
  • Deployment(您已经拥有了)

  • Service选择导出器(取决于您使用的Helm Chart,也许也有)

  • ServiceMonitor声明性地指定应如何监视Kubernetes服务组。操作员根据API服务器中对象的当前状态自动生成Prometheus抓取配置。

  • PrometheusRule定义了一组所需的Prometheus警报和/或记录规则。操作员生成一个规则文件,Prometheus实例可以使用该文件。