【问题标题】:Service monitor issue in Prometheus operatorPrometheus 操作员中的服务监视器问题
【发布时间】:2020-10-27 07:13:43
【问题描述】:

我的 service 和 servicemonitor 定义如下,

kind: Service
apiVersion: v1
metadata:
  name: example-application
  labels:
    app: example-application
    teamname: neon
spec:
  selector:
    app: example-application
  ports:
  - name: backend
    port: 8080
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: example-application
  namespace: monitoring
spec:
  selector:
    matchLabels:
      app: example-application
  endpoints:
  - port: backend
    path: /prometheus
  namespaceSelector:
    matchNames:
    - testns
  targetLabels:
    - teamname

Pods 都可用。我已经测试了服务。

但目标在 Prometheus 中显示为 DOWN。请让我知道我缺少什么。

【问题讨论】:

  • 确保您指定了正确的路径,/prometheus?
  • @KamolHasan ...感谢您的回复...我需要在哪里定义这条路径吗?我只是在服务监视器中提到了这个路径,如上面的代码所示。如果有什么地方我需要添加这个路径,请告诉我。
  • 你可以使用github.com/txn2/kubefwd 转发并尝试curl http://example-application.testns:8080/prometheus 吗?

标签: prometheus-operator


【解决方案1】:

我找到了缺失的部分..我必须在该路径上的应用程序中公开指标..

所以我关注了这篇文章https://medium.com/kubernetes-tutorials/simple-management-of-prometheus-monitoring-pipeline-with-the-prometheus-operator-b445da0e0d1a

出于示例目的,我使用本文中给出的相同图像作为我的部署对象中的指标的边车容器,如下所示,

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: example-application
spec:
  replicas: 4
  template:
    metadata:
      labels:
        app: example-application
    spec:
      containers:
      - name: example-application
        image: nginx
        ports:
        - name: backend
          containerPort: 80
      - name: rpc-app-cont
        image: supergiantkir/prometheus-test-app
        ports:
        - name: web
          containerPort: 8081

然后将此端口“web”添加到服务监视器。

现在它工作正常..

【讨论】:

    猜你喜欢
    • 2022-08-16
    • 1970-01-01
    • 1970-01-01
    • 2020-12-04
    • 2014-11-05
    • 2017-03-30
    • 1970-01-01
    • 2011-02-13
    • 1970-01-01
    相关资源
    最近更新 更多