简体   繁体   English

Kubernetes - Prometheus 缺少所有 NGINX 入口指标?

[英]Kubernetes - Prometheus Missing All NGINX Ingress Metrics?

I have a DigitalOcean Kubernetes cluster.我有一个 DigitalOcean Kubernetes 集群。 I have installed the NGINX Ingress Controller via Helm & also installed Prometheus & Grafana.我已经通过 Helm 安装了 NGINX Ingress Controller 并且还安装了 Prometheus 和 Grafana。

My ingresses are in the default namespace, my monitoring is in a monitoring namespace.我的入口在default命名空间中,我的监控在monitoring命名空间中。

Here are the versions of the charts i have installed.这是我安装的图表版本。

❯ helm list
NAME            REVISION    UPDATED                     STATUS      CHART                   APP VERSION NAMESPACE
grafana         1           Mon Oct  7 08:04:15 2019    DEPLOYED    grafana-3.8.18          6.3.5       monitoring
metrics-server  1           Thu Aug 29 09:07:21 2019    DEPLOYED    metrics-server-2.8.2    0.3.2       kube-system
nginx-ingress   1           Wed Aug 21 21:32:06 2019    DEPLOYED    nginx-ingress-1.17.1    0.25.1      default
prometheus      1           Mon Oct  7 09:24:21 2019    DEPLOYED    prometheus-9.1.2        2.11.1      monitoring

I'm trying to get some NGINX Metrics, so i can monitor in Grafana.我正在尝试获取一些 NGINX 指标,以便我可以在 Grafana 中进行监控。

However, none of them appear in the Prometheus UI.但是,它们都没有出现在 Prometheus UI 中。 I have tried adding the prometheus flags to all my ingresses, but still get nothing.我已经尝试将普罗米修斯标志添加到我所有的入口中,但仍然一无所获。 eg例如

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ****-ingress
  namespace: monitoring
  annotations:
    kubernetes.io/ingress.class: nginx
    enable-vts-status: "true"
    prometheus.io/scrape: "true"
    prometheus.io/port: "10254"

I used the default values.yaml file for the nginx controller, but i did change to enable metrics:我为 nginx controller 使用了默认值。yaml文件,但我确实更改了启用指标:

  metrics:
    enabled: true

From what i read, it should work out of the box.根据我的阅读,它应该开箱即用。 So i have no idea what's going wrong.所以我不知道出了什么问题。

Prometheus 服务发现 普罗米修斯搜索查询

One thing that does look suspicious, is that the service discovery doesn't seem to be monitoring any services, but i've never used Prometheus and i'm at a dead end with what to look for.看起来可疑的一件事是服务发现似乎没有监视任何服务,但我从未使用过 Prometheus,而且我在寻找什么方面陷入了死胡同。

Thank you谢谢

I got there in the end.我最终到了那里。 I have to create a prometheus job, to watch the NGINX Metrics server.我必须创建一个 prometheus 作业,以观看 NGINX Metrics 服务器。 I figured, that difference between my setup and all the examples online (even though i used the same helm charts) is that i have a separate NGINX metrics service, running on a different port.我想,我的设置和所有在线示例之间的区别(即使我使用相同的舵图)是我有一个单独的 NGINX 指标服务,在不同的端口上运行。 So OOB Prometheus was not configured to check it.所以OOB Prometheus 没有被配置为检查它。

- job_name: nginx-ingress
      metrics_path: /metrics
      scrape_interval: 5s
      static_configs:
        - targets:
          - nginx-ingress-controller-metrics:9913

Added that to the prometheus configmap, and reloaded the config.将其添加到 prometheus configmap,并重新加载配置。

It seems that you've deployed Prometheus from scratch.看来您已经从头开始部署 Prometheus。 Nginx ingress metrics work only when you deployed Prometheus via prometheus-operator . Nginx 入口指标仅在您通过prometheus-operator部署 Prometheus 时有效。

I think you can use to find your selectors in the other namespaces also and have them come alive.我认为您也可以使用在其他命名空间中找到您的选择器并让它们活跃起来。 I was running into the same nginx ingress issue you were (same port etc).我遇到了与您相同的 nginx 入口问题(相同的端口等)。 I'm not sure which are the key lines so I added them all but it had mine come alive, and I think it's a bit more future proof.我不确定哪些是关键线,所以我把它们都加了进去,但它让我的活了起来,我认为这对未来有更多的证明。

  values:
    prometheus:
      prometheusSpec:
        # Use all prometheus rules on the cluster
        ruleNamespaceSelector:
          any: true
        ruleSelectorNilUsesHelmValues: false

        # Use all service monitors on the cluster
        serviceMonitorNamespaceSelector:
          any: true
        serviceMonitorSelectorNilUsesHelmValues: false

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

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